Skip to content

[$500] Web - On login with concierge, different chat is displayed before redirecting to concierge #34755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 6 tasks
kbecciv opened this issue Jan 18, 2024 · 37 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Jan 18, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.27-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Open the app
  2. Logout if logged in
  3. Visit concierge link eg: https://staging.new.expensify.com/concierge
  4. Login with user with many chats
  5. Observe that after login, different chat is displayed first before redirecting to concierge page

Expected Result:

App should display concierge page on login with concierge link

Actual Result:

App displays different chat first before redirecting to concierge page on login with concierge link

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6346840_1705601525095.34701_-_login_with_concierge_issue_staging.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01206911560f412311
  • Upwork Job ID: 1748064944878907392
  • Last Price Increase: 2024-02-01
  • Automatic offers:
    • bernhardoj | Contributor | 0
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 18, 2024
Copy link

melvin-bot bot commented Jan 18, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01206911560f412311

@melvin-bot melvin-bot bot changed the title Web - On login with concierge, different chat is displayed before redirecting to concierge [$500] Web - On login with concierge, different chat is displayed before redirecting to concierge Jan 18, 2024
Copy link

melvin-bot bot commented Jan 18, 2024

Triggered auto assignment to @adelekennedy (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 18, 2024
Copy link

melvin-bot bot commented Jan 18, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @sobitneupane (External)

@kbecciv
Copy link
Author

kbecciv commented Jan 18, 2024

@Quintar - #vip-vsb

@dummy-1111
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

When login with concierge, different chat is displayed before redirecting to concierge

What is the root cause of that problem?

When deep linking, openReportFromDeepLink function is called. After signing in, navigates to the deep link url

App/src/libs/actions/Report.ts

Lines 2057 to 2078 in e6b0761

const route = ReportUtils.getRouteFromLink(url);
if (route === ROUTES.CONCIERGE) {
navigateToConciergeChat(true);
return;
}
if (Session.isAnonymousUser() && !Session.canAccessRouteByAnonymousUser(route)) {
Session.signOutAndRedirectToSignIn(true);
return;
}
// We don't want to navigate to the exitTo route when creating a new workspace from a deep link,
// because we already handle creating the optimistic policy and navigating to it in App.setUpPoliciesAndNavigate,
// which is already called when AuthScreens mounts.
if (new URL(url).searchParams.get('exitTo') === ROUTES.WORKSPACE_NEW) {
return;
}
if (shouldSkipDeepLinkNavigation(route)) {
return;
}
Navigation.navigate(route as Route, CONST.NAVIGATION.ACTION_TYPE.PUSH);

When navigating to concierge chat, we wait for openApp or reconnectApp API call and navigate to the concierge chat

App/src/libs/actions/Report.ts

Lines 1582 to 1585 in e6b0761

Welcome.serverDataIsReadyPromise().then(() => {
// If we don't have a chat with Concierge then create it
navigateToAndOpenReport([CONST.EMAIL.CONCIERGE], false);
});

but when navigating to other chat, we just go to the report

Meanwhile, we have ReportScreenIDSetter to go to the last accessed report.

if (route?.params?.reportID) {
const reportActionID = route?.params?.reportActionID;
const regexValidReportActionID = new RegExp(/^\d*$/);
if (reportActionID && !regexValidReportActionID.test(reportActionID)) {
navigation.setParams({reportActionID: ''});
}
App.confirmReadyToOpenApp();
return;
}
// If there is no reportID in route, try to find last accessed and use it for setParams
const reportID = getLastAccessedReportID(reports, !canUseDefaultRooms, policies, isFirstTimeNewExpensifyUser, !!reports?.params?.openOnAdminRoom, reportMetadata);
// It's possible that reports aren't fully loaded yet
// in that case the reportID is undefined
if (reportID) {
navigation.setParams({reportID: String(reportID)});
} else {
App.confirmReadyToOpenApp();
}

As you can see above, route?.params?.reportID is empty and last accessed report exists, we call navigation.setParams({reportID: String(reportID)}). When deep linking to concierge chat, route?.params?.reportID is empty and so navigation.setParams is called, but when linking to other chat, route?.params?.reportID is not empty and navigation.setParams isn't called

This is the root cause

What changes do you think we should make in order to solve the problem?

We shouldn't call navigation.setParams when deep linking to concierge chat

Insert the following code here

let deepLinkRoute: string = '';
Linking.getInitialURL().then((url) => {
    deepLinkRoute = ReportUtils.getRouteFromLink(url);
});

Update

navigation.setParams({reportID: String(reportID)});

to

            if (deepLinkRoute !== ROUTES.CONCIERGE) {
                navigation.setParams({reportID: String(reportID)});
            }

This works as expected

Result
34755.mp4

What alternative solutions did you explore? (Optional)

@bernhardoj
Copy link
Contributor

bernhardoj commented Jan 19, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

When going to /concierge and login, the app shows other report briefly before the concierge chat.

What is the root cause of that problem?

When we navigate to /concierge, we actually being navigated to ConciergePage.

function ConciergePage({session}: ConciergePageProps) {
useFocusEffect(() => {
if (session && 'authToken' in session) {
// Pop the concierge loading page before opening the concierge report.
Navigation.isNavigationReady().then(() => {
Navigation.goBack(ROUTES.HOME);
Report.navigateToConciergeChat();
});
} else {
Navigation.navigate();
}
});
return <FullScreenLoadingIndicator />;
}

Before going to the concierge chat, it will pop the current screen, that is the ConciergePage itself. But navigateToConciergeChat will wait until the initial load of the app to complete.

App/src/libs/actions/Report.ts

Lines 1579 to 1585 in 991a4e2

if (!conciergeChatReportID || ignoreConciergeReportID) {
// In order to avoid creating concierge repeatedly,
// we need to ensure that the server data has been successfully pulled
Welcome.serverDataIsReadyPromise().then(() => {
// If we don't have a chat with Concierge then create it
navigateToAndOpenReport([CONST.EMAIL.CONCIERGE], false);
});

So, the ConciergePage utility page is gone, but we are still not navigated to the concierge page yet.

Then, we have a logic to have at least one report screen on the stack which will show the last accessed report.

if (!isAtLeastOneCentralPaneNavigatorInState(partialState) && !options.getIsSmallScreenWidth()) {
// If we added a route we need to make sure that the state.stale is true to generate new key for this route
// eslint-disable-next-line no-param-reassign
(partialState.stale as boolean) = true;
addCentralPaneNavigatorRoute(partialState);
}

So, the nav stack will be: [Home, ReportScreen], and when navigateToConciergeChat is done, concierge chat is added to the stack: [Home, ReportScreen, ReportScreen (Concierge)].

What changes do you think we should make in order to solve the problem?

First, we should wait until navigateToConciergeChat is complete before popping out the ConciergePage. But as we are not allowed to do promise chaining in a component, we can pass a new param to navigateToConciergeChat that will pop the current screen after navigating to concierge chat, or just replace the current screen with concierge chat.

Report.navigateToConciergeChat(false, true <- shouldPopCurrentScreen); or
Report.navigateToConciergeChat(false, CONST.NAVIGATION.TYPE.FORCED_UP);

With this change, we will see ConciergePage (which shows a loading screen) instead of a report screen.
image

If we want to show a report skeleton on the concierge page, we can add ReportHeaderSkeletonView and ReportActionsSkeletonView to the component like below:

return (
    <>
        <View style={[styles.borderBottom]}>
            <ReportHeaderSkeletonView onBackButtonPress={Navigation.goBack} />
        </View>
        <ReportActionsSkeletonView />
    </>
);

Here is what it looks like:

Screen.Recording.2024-02-06.at.17.23.26.mov

But the report screen added by CustomRouter still exists on the nav stack: [Home, ReportScreen, ReporScreen (Concierge)]. To prevent this, we can avoid adding it if ConciergePage is in the stack.

if (!isAtLeastOneCentralPaneNavigatorInState(partialState) && !options.getIsSmallScreenWidth()) {

const isConciergePageInState = (state: State): boolean => !!state.routes.find((route) => route.name === SCREENS.CONCIERGE);

&& !isConciergePageInState(partialState)

Last, we need to call App.confirmReadyToOpenApp() in ConciergePage inside the if. App.confirmReadyToOpenApp() is previously called in ReportScreenIDSetter, but since we don't add report screen to the stack anymore, we need to call it in ConciergePage.

if (session && 'authToken' in session) {
// Pop the concierge loading page before opening the concierge report.
Navigation.isNavigationReady().then(() => {

@adelekennedy
Copy link

@sobitneupane two proposals above to review!

@sobitneupane
Copy link
Contributor

I am working partially this week. I will try to review the proposals before weekend.

@melvin-bot melvin-bot bot removed the Overdue label Jan 24, 2024
Copy link

melvin-bot bot commented Jan 25, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot melvin-bot bot added the Overdue label Jan 29, 2024
Copy link

melvin-bot bot commented Jan 29, 2024

@sobitneupane, @adelekennedy Huh... This is 4 days overdue. Who can take care of this?

@adelekennedy
Copy link

we have proposals - @sobitneupane will review when back

@melvin-bot melvin-bot bot removed the Overdue label Jan 30, 2024
Copy link

melvin-bot bot commented Feb 1, 2024

@sobitneupane @adelekennedy this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@sobitneupane
Copy link
Contributor

i will review the proposals by EOD.

Copy link

melvin-bot bot commented Feb 1, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@sobitneupane
Copy link
Contributor

Thanks for the proposal everyone.

Special thanks to @bernhardoj for detailed RCA. Overall, your proposal looks good to me.

With this change, we will see ConciergePage (which shows a loading screen) instead of a report screen.

@bernhardoj Should we show SkeletonView instead of loading screen?

@bernhardoj
Copy link
Contributor

I think it's fine to show the loading screen as it's just an intermediary screen and only noticeable when opening it while the app is still loading.

@sobitneupane
Copy link
Contributor

I believe we have replace the loading screen by SkeletonView in most of the places. And it's good to do have the change here as well. Is there any reason to not have SkeletonView here?

@bernhardoj
Copy link
Contributor

I don't really have a strong reason, but I see all intermediary pages only show a loading screen (LogOutPreviousUserPage, demo page - not exist anymore), so I think we can just leave it as it is.

If we want to add a skeleton, what would it look like? Do we want to show the header and report skeleton without the composer?

Copy link

melvin-bot bot commented Feb 8, 2024

@sobitneupane @jasperhuangg @adelekennedy this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

@adelekennedy
Copy link

@jasperhuangg will you check the approved proposal?

@jasperhuangg
Copy link
Contributor

On it, thanks for the bump. Been OOO the last two days.

@jasperhuangg
Copy link
Contributor

@bernhardoj's proposal also makes sense to me, great explanation!

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 8, 2024
Copy link

melvin-bot bot commented Feb 8, 2024

📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@bernhardoj
Copy link
Contributor

PR is ready

cc: @sobitneupane

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Mar 4, 2024
Copy link

melvin-bot bot commented Mar 4, 2024

This issue has not been updated in over 15 days. @sobitneupane, @jasperhuangg, @bernhardoj, @adelekennedy eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@jasperhuangg
Copy link
Contributor

PR was deployed to prod a few days ago without any regressions!

@jasperhuangg jasperhuangg added Weekly KSv2 Monthly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 Weekly KSv2 labels Mar 4, 2024
@jasperhuangg
Copy link
Contributor

Seems there's been a problem with melvin adding the awaiting payment labels

@jasperhuangg jasperhuangg added Weekly KSv2 and removed Monthly KSv2 labels Mar 4, 2024
@jasperhuangg
Copy link
Contributor

It looks like we need to pay out:
@bernhardoj for opening the PR
@sobitneupane for reviewing the PR

@adelekennedy can you send them offers?

@adelekennedy
Copy link

Payouts due:

Contributor: $500 @bernhardoj Upwork
Contributor+: $500 @sobitneupane NewDot

@adelekennedy
Copy link

made upwork payment and posted bz payment summary above

@JmillsExpensify
Copy link

$500 approved for @sobitneupane based on summary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

7 participants