Skip to content

[HOLD for payment 2023-12-28] [$500] Workspace - Currencies do not load after transition from OldDot when other user logged in ND #31789

Closed

Description

@lanitochka17

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: 1.4.3-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. Navigate to OldDot Expensify and log in with an existing account which has a workspace
  2. Open new tab > navigate to NewDot Expensify and log in with different account
  3. In the OldDot tab, navigate to the workspace and click on it
  4. Click on Settings > Default currency

Expected Result:

A list of all available currencies should be shown

Actual Result:

The list is empty, even the default currency is not shown

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

Bug6288641_1700751338403.2023-11-23_15-20-07.mp4

Bug6288641_1700751338388!chrome_IGeqITBXT9

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019bf54ae70b3509e1
  • Upwork Job ID: 1727745677732249600
  • Last Price Increase: 2023-11-23
  • Automatic offers:
    • cubuspl42 | Reviewer | 27885178
    • AmjedNazzal | Contributor | 27885180
Issue OwnerCurrent Issue Owner: @cubuspl42

Activity

  1. added
    External
    Daily
    Bug
    on Nov 23, 2023
  2. changed the title [-]Workspace - Currencies do not load after transition from OldDot when other user logged in ND[/-] [+][$500] Workspace - Currencies do not load after transition from OldDot when other user logged in ND[/+] on Nov 23, 2023
  3. melvin-bot commented on Nov 23, 2023

    @melvin-bot
  4. melvin-bot commented on Nov 23, 2023

    @melvin-bot

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

  5. melvin-bot commented on Nov 23, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  6. added
    Help Wanted
    on Nov 23, 2023
  7. melvin-bot commented on Nov 23, 2023

    @melvin-bot

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

  8. zukilover commented on Nov 24, 2023

    @zukilover
    Contributor

    Proposal

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

    Currency list is not loaded when transitioning from OldDot to NewDot with different account.

    What is the root cause of that problem?

    Currency list is loaded by openApp() method. In AuthScreens, when transitioning, this method will be called if app is logging as a new user (different user):

    const isLoggingInAsNewUser = SessionUtils.isLoggingInAsNewUser(currentUrl, session.email);
    const shouldGetAllData = isUsingMemoryOnlyKeys || SessionUtils.didUserLogInDuringSession() || isLoggingInAsNewUser;

    The problem is, upon transitioning to a new user, app is logging out:

    if (isLoggingInAsNewUser && isTransitioning) {
    Session.signOutAndRedirectToSignIn();
    return;
    }

    then redirected to LogInWithShortLivedAuthTokenPage to initiate signInWithShortLivedAuthToken:

    if (shortLivedAuthToken && !props.account.isLoading) {
    Session.signInWithShortLivedAuthToken(email, shortLivedAuthToken);
    return;
    }

    In this state, user has logged in with the email from the transition, i.e. email from the URL params is the same as the session email, thus the app is treating it as a login from the same email.

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

    There needs to be a way of storing the previous session's email so that it can be compared accurately with the email from the new session.

    1. Add new property in the Session store:
         /** The user's email of the previous session */
        previousSessionEmail?: string;
    1. Create new utility to store the previous session email:
    function setPreviousSessionEmail(email: string) {
        Onyx.merge(ONYXKEYS.SESSION, {previousSessionEmail: email});
    }
    1. In LogInWithShortLivedAuthTokenPage, we store the email before logging in with the new one:
           if (shortLivedAuthToken && !props.account.isLoading) {
                Session.setPreviousSessionEmail(props.session.email)
                Session.signInWithShortLivedAuthToken(email, shortLivedAuthToken);
                return;
            }
    1. Compare the emails to mark the login session as a new login in AuthScreen:
    const isTransitioningFromUser = SessionUtils.isLoggingInAsNewUser(currentUrl, session.previousSessionEmail);
    const shouldGetAllData = isUsingMemoryOnlyKeys || SessionUtils.didUserLogInDuringSession() || isLoggingInAsNewUser || isTransitioningFromUser;

    What alternative solutions did you explore? (Optional)

    N/A

  9. conorpendergrast commented on Nov 24, 2023

    @conorpendergrast

    Reproduced. Seems like it could be relatively rare in the real world, but we have plenty of customers with multiple user accounts!

  10. AmjedNazzal commented on Nov 24, 2023

    @AmjedNazzal
    Contributor

    Proposal

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

    Workspace - Currencies do not load after transition from OldDot when other user logged in ND

    What is the root cause of that problem?

    The cause of this issue starts in this code:

    Onyx.connect({
    key: ONYXKEYS.SESSION,
    callback: (session) => {
    if (loggedInDuringSession) {
    return;
    }
    if (session?.authToken) {
    loggedInDuringSession = false;
    } else {
    loggedInDuringSession = true;
    }
    },
    });

    So in this code we are returning false if session?.authToken, and since we are deeplinking to the workspace settings from OD we would be using Session.signInWithShortLivedAuthToken which means session?.authToken will be indeed populated resulting in AuthScreens to call App.reconnectApp instead of App.openApp resulting in the onyx store not getting populated properly which is the reason that as you will see in the screenshot below, the LHN would be not populated either:

    nolhn

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

    We can do the following:

    1. We would add a new entry to Session.ts to watch for if the login was with short lived token
    signedInWithShortLivedAuthToken?: boolean;
    1. We would then add a temporary onyx merge in signInWithShortLivedAuthToken within the optimisticData but remove it in successData to allow App.openApp to be called at least once when using short lived token
    function signInWithShortLivedAuthToken(email: string, authToken: string) {
      const optimisticData: OnyxUpdate[] = [
          .....
          {
              onyxMethod: Onyx.METHOD.MERGE,
              key: ONYXKEYS.SESSION,
              value: {
                  signedInWithShortLivedAuthToken: true,
              },
          },
      ];
      const successData: OnyxUpdate[] = [
          ....
          {
              onyxMethod: Onyx.METHOD.MERGE,
              key: ONYXKEYS.SESSION,
              value: {
                  signedInWithShortLivedAuthToken: undefined,
              },
          },
    ];
    1. Finally in SessionUtils.isLoggingInAsNewUser we would check this new session value and if it's true we return true for loggedInDuringSession
    Onyx.connect({
      key: ONYXKEYS.SESSION,
      callback: (session) => {
        ....
        if (session?.signedInWithShortLivedAuthToken) {
          loggedInDuringSession = true;
        }

    Result

    Screen.Recording.2023-11-24.at.12.41.21.PM.mov
  11. 38 remaining items

  12. added
    Bug
    on Jan 4, 2024
  13. melvin-bot commented on Jan 4, 2024

    @melvin-bot

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

  14. deleted a comment from melvin-bot on Jan 4, 2024
  15. thienlnam commented on Jan 4, 2024

    @thienlnam
    Contributor

    Adding another BZ member that can issue payment while Connor is OOO - cc @sophiepintoraetz Looks like this is ready for payment

  16. sophiepintoraetz commented on Jan 4, 2024

    @sophiepintoraetz
    Contributor

    We did say that payments might be a little slower with the holidays but in any case, I have paid @AmjedNazzal - just waiting on @cubuspl42 to complete the checklist.

  17. jakub-trzebiatowski commented on Jan 5, 2024

    @jakub-trzebiatowski
    Contributor
    • The PR that introduced the bug has been identified. Link to the PR:
      • N/A (This is an interaction between OldDot and NewDot, both sides would need to be analyzed to point to specific PRs with certainty, while the OldDot code is not available)
    • 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:
      • N/A
    • A discussion in #expensify-bugs 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:
      • No need for additional discussion
    • Determine if we should create a regression test for this bug.
      • Up to the QA team
    • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
      • Sign in to OldDot using account A
      • Sign in to NewDot using a different account B
        • Use the same environment (staging or prod) you used for OldDot
      • From OldDot, go to Settings > Workspaces and click on a workspace
      • Once the NewDot app loads, go to (Your workspace) > Settings > Default currency and verify that the currency list is populated
  18. melvin-bot commented on Jan 8, 2024

    @melvin-bot

    @francoisl, @cubuspl42, @conorpendergrast, @sophiepintoraetz, @AmjedNazzal Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  19. conorpendergrast commented on Jan 8, 2024

    @conorpendergrast

    This was caught by Applause during testing, so I think it's already captured under existing regression testing. I think it's likely we don't need a new test as a result, but if anyone disagrees, comment and let me know!

    Apart from that, we're all done here. Thanks!

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions