Skip to content

[$250] mWeb - Concierge chat appears twice after logging in via Concierge deeplink #60859

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.1.32-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5989784
Email or phone of affected tester (no customers): n.a
Issue reported by: Applause Internal Team
Device used: iphone promax 13, IOS 18.3.2
App Component: Other

Action Performed:

Steps:

  1. Log out of NewDot
  2. Navigate the link https://staging.new.expensify.com/concierge on Safari browser
  3. Logged in with existing account
  4. Observe that user navigate to the Concierge chat after login
  5. Tap back arrow and there is another concierge chat after login
  6. Tap back arrow, users now back to the inbox

Expected Result:

When a user logs in with an existing account via the Concierge link, the Concierge chat appears only once.

Actual Result:

When user logged in with existing account via https://staging.new.expensify.com/concierge, the Concierge chat appear twice. Issue occured on both mweb Android and iOS

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021915505151324649989
  • Upwork Job ID: 1915505151324649989
  • Last Price Increase: 2025-05-01
Issue OwnerCurrent Issue Owner: @maddylewis

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 24, 2025
  2. melvin-bot commented on Apr 24, 2025

    @melvin-bot

    Triggered auto assignment to @maddylewis (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. truph01 commented on Apr 24, 2025

    @truph01
    Contributor

    Proposal

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

    What is the root cause of that problem?

    • This callback function is being invoked twice after login. Consequently, the navigation action is also triggered twice, resulting in the Concierge chat opening twice when logging in through the Concierge deeplink.

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

    • After the line where the callback is set (link), we should call:
    Onyx.disconnect(connection);

    This will unsubscribe from the Onyx connection, ensuring the callback is not triggered more than once.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    • None.

    What alternative solutions did you explore? (Optional)

    • An alternative approach would be to implement a guard flag to ensure navigation only happens once. For example:
      Navigation.navigate(route as Route);
    
    if (!isNavigationTriggered) {
        Navigation.navigate(route as Route);
        isNavigationTriggered = true;
    }
    
  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 24, 2025
  5. changed the title [-]mWeb - Concierge chat appears twice after logging in via Concierge deeplink[/-] [+][$250] mWeb - Concierge chat appears twice after logging in via Concierge deeplink[/+] on Apr 24, 2025
  6. melvin-bot commented on Apr 24, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 24, 2025
  8. melvin-bot commented on Apr 24, 2025

    @melvin-bot

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

  9. bernhardoj commented on Apr 25, 2025

    @bernhardoj
    Contributor

    Proposal

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

    Concierge chat is opened twice when deeplink to it while logged out.

    What is the root cause of that problem?

    The deeplink while logged out is handled here.

    App/src/libs/actions/Report.ts

    Lines 3273 to 3342 in 2d3950e

    InteractionManager.runAfterInteractions(() => {
    waitForUserSignIn().then(() => {
    const connection = Onyx.connect({
    key: ONYXKEYS.NVP_ONBOARDING,
    callback: () => {
    Navigation.waitForProtectedRoutes().then(() => {
    if (route && isAnonymousUser() && !canAnonymousUserAccessRoute(route)) {
    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 (url && new URL(url).searchParams.get('exitTo') === ROUTES.WORKSPACE_NEW) {
    return;
    }
    const handleDeeplinkNavigation = () => {
    // We want to disconnect the connection so it won't trigger the deeplink again
    // every time the data is changed, for example, when relogin.
    Onyx.disconnect(connection);
    const state = navigationRef.getRootState();
    const currentFocusedRoute = findFocusedRoute(state);
    if (isOnboardingFlowName(currentFocusedRoute?.name)) {
    setOnboardingErrorMessage(Localize.translateLocal('onboarding.purpose.errorBackButton'));
    return;
    }
    if (shouldSkipDeepLinkNavigation(route)) {
    return;
    }
    if (isAuthenticated) {
    return;
    }
    // Check if the report exists in the collection
    const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
    // If the report does not exist, navigate to the last accessed report or Concierge chat
    if (reportID && !report) {
    const lastAccessedReportID = findLastAccessedReport(false, shouldOpenOnAdminRoom(), undefined, reportID)?.reportID;
    if (lastAccessedReportID) {
    const lastAccessedReportRoute = ROUTES.REPORT_WITH_ID.getRoute(lastAccessedReportID);
    Navigation.navigate(lastAccessedReportRoute);
    return;
    }
    navigateToConciergeChat(false, () => true);
    return;
    }
    Navigation.navigate(route as Route);
    };
    if (isAnonymousUser()) {
    handleDeeplinkNavigation();
    return;
    }
    // We need skip deeplinking if the user hasn't completed the guided setup flow.
    isOnboardingFlowCompleted({
    onNotCompleted: () => startOnboardingFlow(),
    onCompleted: handleDeeplinkNavigation,
    onCanceled: handleDeeplinkNavigation,
    });
    });
    },
    });
    });

    It will wait until the user is logged in and then connect to the onboarding onyx data. When logged in, the data is initially undefined, and then changed to the onboarding data. Because of this, the onyx callback is called twice, leading to two navigation.

    We connect to the onboarding data to prevent the deeplink if the user needs to complete the onboarding first, implemented in #44536. But now, we don't use the onboarding data anymore, instead, we use the isOnboardingFlowCompleted.

    App/src/libs/actions/Report.ts

    Lines 3333 to 3338 in 2d3950e

    // We need skip deeplinking if the user hasn't completed the guided setup flow.
    isOnboardingFlowCompleted({
    onNotCompleted: () => startOnboardingFlow(),
    onCompleted: handleDeeplinkNavigation,
    onCanceled: handleDeeplinkNavigation,
    });

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

    Remove the onyx connect. But, this will now totally prevent a new user to deep link. I know that #44536 prevents it, but #49092 "changes" it, so that after completing the onboarding, the user is navigated to the deeplink. This is possible because we will only disconnect the onyx callback after the navigation is done.

    If we want to prevent it back, then remove the onyx connect. Else, we can keep the onyx connect, but return early if the onboarding data is empty.

    const connection = Onyx.connect({
        key: ONYXKEYS.NVP_ONBOARDING,
        callback: (val) => {
            if (!val) {
                return;
            }
    

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    N/A

  10. eh2077 commented on Apr 25, 2025

    @eh2077
    Contributor

    Reviewing proposals

  11. melvin-bot commented on Apr 29, 2025

    @melvin-bot

    @eh2077 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  12. 18 remaining items

  13. eh2077 commented on Jun 20, 2025

    @eh2077
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/49092/files#r2158052495

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • NA

    Test:

    1. Log out
    2. Open /concierge (staging.new.expensify.com/concierge) and then login
    3. After the concierge chat opens, press the header back button (not applicable to web and desktop)
    4. Verify you arrived at the LHN

    Do we agree 👍 or 👎

  14. bernhardoj commented on Jun 20, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  15. melvin-bot commented on Jun 25, 2025

    @melvin-bot

    @maddylewis Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  16. melvin-bot commented on Jun 27, 2025

    @melvin-bot

    @maddylewis Eep! 4 days overdue now. Issues have feelings too...

  17. melvin-bot commented on Jun 30, 2025

    @melvin-bot

    @maddylewis Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

  18. melvin-bot commented on Jul 2, 2025

    @melvin-bot

    @maddylewis 10 days overdue. I'm getting more depressed than Marvin.

  19. JmillsExpensify commented on Jul 2, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  20. melvin-bot commented on Jul 4, 2025

    @melvin-bot

    @maddylewis 12 days overdue now... This issue's end is nigh!

  21. melvin-bot commented on Jul 7, 2025

    @melvin-bot

    This issue has not been updated in over 14 days. @AndrewGable, @maddylewis, @bernhardoj, @eh2077 eroding to Weekly issue.

  22. JmillsExpensify commented on Jul 14, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @eh2077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions