Skip to content

[$250] 2FA - User admin is redirected to NewDot instead of completing the OldDot 2FA flow for Xero #102437

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.94-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/75704627/folder/13176909/41237458/1798309092?sort=%2Bidentifier
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Android 16 / Honor x6b
App Component: Other

Action Performed:

Precondition: User A has already set Xero connection

Test 2 — OldDot Flow (Android and iOS only)

  1. Create a new account (User B) in the Hybrid App.
  2. Navigate to Settings and switch to Expensify Classic.
  3. Sign out from Classic (OldDot).
  4. As User A, add User B's account to the workspace where the Xero connection is established.
  5. Make sure User B is invited as an Admin.
  6. Sign in as User B in the Hybrid App.
  7. Enter the magic code.
  8. Verify that a prompt to enable 2FA is displayed from OldDot.
    Result: User is redirected to the NewDot 2FA flow.
  9. Click Enable 2FA.
    Result: Security tab with interactive tep analysis modal appears briefly
  10. Validate the account with the magic code if prompted.
  11. Complete the 2FA setup flow.
    Result: After entering the authentication code, the current step restarts and prompts the user to enter the authentication code again.
  12. Click Got it.
  13. Verify that all OldDot content loads properly.
    Result: User remains in NewDot.

Expected Result:

When signin User B must land in Old to enable 2FA. After entering the authentication code during the 2FA setup, the authentication step should complete successfully, and the user should remain in OldDot with all OldDot content loaded properly.

Actual Result:

When signin User B must land in ND to enable 2FA. After entering the authentication code, the authentication step restarts and prompts the user to enter the code again. After clicking Got it, the user is taken directly to NewDot instead of loading OldDot content.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7271611_1790606600227.document_5030948313407424565.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7271611

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @madmax330

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 28, 2026
  2. applause-bot commented on Sep 28, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/657b6def396938605cbcb4424bbc08ac17a8f4fed49ca0ad9c55e42d9bb810be

  3. changed the title [-]2FA-User admin is redirected to NewDot instead of completing the OldDot 2FA flow for Xero[/-] [+]2FA - User admin is redirected to NewDot instead of completing the OldDot 2FA flow for Xero[/+] on Sep 28, 2026
  4. MelvinBot commented on Sep 28, 2026

    @MelvinBot
    Contributor

    Proposal

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

    A HybridApp user who must set up 2FA completes the NewDot 2FA flow, but the verify step restarts after a valid code. When they tap "Got it", they stay in NewDot instead of going back to Expensify Classic (OldDot).

    What is the root cause of that problem?

    There are three parts to this issue:

    1. Landing in NewDot is intended. HybridApp.ts:120 keeps users in NewDot until they finish required 2FA. fix: keep user in ND until they setup 2FA when required added this after OldDot skipped the 2FA screen. The test case expects an OldDot 2FA prompt, which is out of date.
    2. "Got it" can't find the Classic redirect flag. DynamicSuccessPage.tsx:97 only returns to OldDot when nvp_tryNewDot.classicRedirect.dismissed is true. After a valid code, validateTwoFactorAuth clears Onyx in both branches (Session/index.ts:1492-1521). NVP_TRY_NEW_DOT is not in either list of kept keys (App.ts:144-170). In the forced-onboarding branch, openApp() waits until "Got it", so the flag is always missing and the user goes to NewDot. Required 2FA setup screen is unresponsive, blocking new-domain login and account merge added that branch.
    3. The verify step restarts. The same Onyx wipe removes HAS_LOADED_APP and personal details while OpenApp is loading. useIsAgentAccount then returns undefined. As a result, withAgentAccessDenied renders null, which unmounts the verify page, and the page mounts again with an empty code field. [No QA] Use server agent identity in App added this gate.

    The Security tab flash in step 9 comes from the overlay route change to ROUTES.SETTINGS_SECURITY (RequireTwoFactorAuthenticationOverlay.tsx:95), which also came from PR 94486.

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

    1. Keep ONYXKEYS.NVP_TRY_NEW_DOT in both lists of kept keys in validateTwoFactorAuth. This lets "Got it" run the existing closeReactNativeApp check. It is the same account, so keeping this value is safe.
    2. Stop the 2FA screens from unmounting during the post-2FA OpenApp. For example, useIsAgentAccount could keep the last known value for the same account, or the wipe could keep HAS_LOADED_APP and the current user's personal details.
    3. Add unit tests for both cases:
      • On HybridApp, with classicRedirect.dismissed = true, "Got it" calls closeReactNativeApp.
      • The verify page stays mounted through the reconnect.

    What alternative solutions did you explore? (Optional)

    • When HybridApp.ts:120 keeps the user in NewDot only because of 2FA, save a flag in ONYXKEYS.HYBRID_APP, which already survives the wipe. The success page would read the flag and then clear it. This matches the original sign-in decision more closely, including when classicRedirect is empty.
    • Build the overlay route from the current screen, as before PR 94486, except in forced onboarding. This removes the Security tab flash.
    Confidence and open questions
    • Confidence: medium. I checked the code paths in App. I did not confirm User B's state in logs or reproduce the bug. This bug needs a real HybridApp build, so I could not test it on web.
    • It's unconfirmed which branch User B took. That depends on nvp_onboarding.hasCompletedGuidedSetupFlow. In the other branch, openApp() runs right away, so "Got it" works only if OpenApp returns nvp_tryNewDot first.
    • Product should confirm that NewDot should still handle required 2FA for Classic users. If it should, update step 8 of the test case.
    • The root cause and fix are both in App.

    Possibly related: [$250] Required 2FA setup screen is unresponsive, blocking new-domain login and account merge is the issue that PR 94486 fixed.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/102437) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 28, 2026
  6. melvin-bot commented on Sep 28, 2026

    @melvin-bot

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

  7. changed the title [-]2FA - User admin is redirected to NewDot instead of completing the OldDot 2FA flow for Xero[/-] [+][$175] 2FA - User admin is redirected to NewDot instead of completing the OldDot 2FA flow for Xero[/+] on Sep 28, 2026
  8. melvin-bot commented on Sep 28, 2026

    @melvin-bot
  9. ashusatyarthi-wq commented on Sep 28, 2026

    @ashusatyarthi-wq

    Proposal

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

    In HybridApp (Android/iOS), when a user invited as an Admin to a workspace connected to Xero is required to set up 2FA, they are redirected to NewDot to complete 2FA setup. However:

    1. After entering the 2FA authentication code during the setup flow, the verification step restarts and prompts the user to enter the code again.
    2. After tapping "Got it" on the success page, the user remains in NewDot instead of being redirected back to Expensify Classic (OldDot) with OldDot content loaded.

    What is the root cause of that problem?

    There are two interrelated root causes:

    1. Failure to return to OldDot ("Got it" button):
      In src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx (lines 97–100):

      if (CONFIG.IS_HYBRID_APP && isClassicRedirectDismissed && !isClassicRedirectBlocked) {
          closeReactNativeApp({shouldSetNVP: false, isTrackingGPS: false});
          return;
      }

      isClassicRedirectDismissed relies on tryNewDot?.classicRedirect?.dismissed from ONYXKEYS.NVP_TRY_NEW_DOT.
      However, during 2FA validation in src/libs/actions/Session/index.ts (validateTwoFactorAuth), clearOnyxAndSeedFullReconnect is called to wipe stale pre-2FA Onyx data.
      Neither KEYS_TO_PRESERVE in src/libs/actions/App.ts (lines 144–171) nor keysToPreserveForForcedOnboarding2FA / keysToPreserveWithPrivatePersonalDetails in Session/index.ts preserve ONYXKEYS.NVP_TRY_NEW_DOT.
      Because NVP_TRY_NEW_DOT is wiped and openApp() has not yet repopulated it before the user taps "Got it", tryNewDot is undefined, isClassicRedirectDismissed evaluates to undefined (falsy), and the app skips closeReactNativeApp(), leaving the user stranded in NewDot.

    2. Verification step restarting after entering code:
      When clearOnyxAndSeedFullReconnect wipes Onyx data upon code submission, ONYXKEYS.PERSONAL_DETAILS_LIST and ONYXKEYS.HAS_LOADED_APP are stripped.
      In src/libs/Navigation/AppNavigator/withAgentAccessDenied.tsx:

      const isAgent = useIsAgentAccount();

      useIsAgentAccount() depends on the current user's entry in PERSONAL_DETAILS_LIST. When stripped, useIsAgentAccount() temporarily returns undefined, causing withAgentAccessDenied to render null. This unmounts the active TwoFactorAuth flow screens. Once the reconnection resolves and sets Onyx state, the component remounts from scratch with empty input fields, making it appear to the user as if the verification step restarted.


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

    1. Preserve ONYXKEYS.NVP_TRY_NEW_DOT across 2FA reconnects:
      In src/libs/actions/App.ts:
      Add ONYXKEYS.NVP_TRY_NEW_DOT to KEYS_TO_PRESERVE so that HybridApp routing state and Classic redirect preferences survive Onyx wipes during 2FA validation:

      diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts
      --- a/src/libs/actions/App.ts
      +++ b/src/libs/actions/App.ts
      @@ -167,6 +167,7 @@ const KEYS_TO_PRESERVE: OnyxKey[] = [
           ONYXKEYS.NVP_LAST_DISMISSED_MARKETING_WINDOW,
      +    ONYXKEYS.NVP_TRY_NEW_DOT,
           ONYXKEYS.IS_USING_IMPORTED_STATE,
       ];

      (Additionally, include ONYXKEYS.NVP_TRY_NEW_DOT in keysToPreserveForForcedOnboarding2FA in src/libs/actions/Session/index.ts to ensure explicit coverage across all onboarding branches).

    2. Prevent premature unmount during 2FA validation in Session/index.ts:
      In src/libs/actions/Session/index.ts:
      Preserve ONYXKEYS.PERSONAL_DETAILS_LIST alongside ONYXKEYS.PRIVATE_PERSONAL_DETAILS in keysToPreserveForForcedOnboarding2FA and keysToPreserveWithPrivatePersonalDetails. This prevents useIsAgentAccount from resolving to undefined during reconnect, keeping the 2FA verification and success screens stable and mounted throughout the transition.

    3. Fallback in DynamicSuccessPage.tsx:
      In DynamicSuccessPage.tsx, check isClassicRedirectDismissed with fallback to ONYXKEYS.HYBRID_APP state if tryNewDot metadata is still resolving, guaranteeing closeReactNativeApp is reliably dispatched on HybridApp.


    What alternative solutions did you explore? (Optional)

    • Storing a temporary routing flag exclusively in ONYXKEYS.HYBRID_APP: While HYBRID_APP is preserved, ONYXKEYS.NVP_TRY_NEW_DOT represents the source of truth for user preference between NewDot and Classic across the app. Preserving NVP_TRY_NEW_DOT directly in KEYS_TO_PRESERVE is architecturally cleaner and prevents regression across other HybridApp transitions.

    Contributor details:
    Your Expensify account email: ashusatyarthi@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~010e53044b5828fe60

  10. franklincg commented on Sep 28, 2026

    @franklincg

    Proposal

    Root cause

    The HybridApp is correctly keeping a user in NewDot while 2FA is required. The regression happens when the 2FA validation path clears and reseeds Onyx before the success screen decides whether it should hand control back to Classic.

    For the normal forced-2FA path, ToggleTwoFactorAuthForm sets shouldClearData when needsTwoFactorAuthSetup is true. validateTwoFactorAuth() then calls clearOnyxAndSeedFullReconnect([...KEYS_TO_PRESERVE, PRIVATE_PERSONAL_DETAILS]).

    The problem is that KEYS_TO_PRESERVE does not include ONYXKEYS.NVP_TRY_NEW_DOT. The success page later checks:

    tryNewDot?.classicRedirect?.dismissed

    to decide whether Got it should call closeReactNativeApp(). By then the Classic redirect state can already have been removed by the 2FA reconnect, so the success page falls through and remains in NewDot.

    That same reconnect is also why the verify step can briefly restart: the 2FA flow is still mounted while account/session state is being cleared and rebuilt.

    Fix

    I would keep the existing “stay in NewDot until required 2FA is complete” behavior and make the post-validation handoff preserve the HybridApp redirect intent across the reconnect.

    Concretely:

    • preserve ONYXKEYS.NVP_TRY_NEW_DOT in the login-required 2FA clear/reseed path used by HybridApp;
    • keep the current post-validate auth token update before reconnect;
    • make sure the success screen is allowed to complete before the Classic handoff, so a reconnect cannot remount the verify step underneath it;
    • after success, let the existing DynamicSuccessPage condition close NewDot only when Classic redirect is actually requested and not blocked.

    I would not change HybridApp.signInToOldDotAndChooseExperience() to send the user to OldDot before 2FA. That would undo the intentional fix that keeps required-2FA users in NewDot until setup is complete.

    Validation

    I would cover:

    1. HybridApp + Classic redirect + required 2FA → verify once, success, Got it returns to OldDot.
    2. HybridApp + required 2FA without Classic redirect → remains in NewDot.
    3. Existing forced-onboarding 2FA handoff still resumes onboarding.
    4. Normal Settings > Security 2FA remains unchanged.

    This keeps the fix scoped to preserving the redirect state across the 2FA reconnect rather than changing the intended HybridApp routing policy.

  11. melvin-bot commented on Oct 1, 2026

    @melvin-bot

    @thesahindia Whoops! This issue is 2 days overdue. Let's get this updated quick!

  12. 47 remaining items

  13. github-actions commented on Oct 15, 2026

    @github-actions
    Contributor

    ⚠️ @open5588 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  14. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 15, 2026
  15. huult commented on Oct 16, 2026

    @huult
  16. huult commented on Oct 16, 2026

    @huult
  17. open5588 commented on Oct 16, 2026

    @open5588

    @huult Great catch on what happens at 0:12! I traced why clicking "Clear cache and restart" makes "Switch to Expensify Classic" appear briefly for an ineligible account:

    1. In TroubleshootPage.tsx (lines 79–92), confirming "Clear cache and restart" calls clearOnyxAndResetApp() (src/libs/actions/App.ts#L617-L672), which runs clearOnyxAndSeedFullReconnect(KEYS_TO_PRESERVE) followed by openApp().
    2. Because ONYXKEYS.NVP_TRY_NEW_DOT is not in KEYS_TO_PRESERVE, tryNewDot becomes undefined immediately while openApp() is in flight. At the same time, useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT) has tryNewDotMetadata.status === 'loaded', so isLoadingTryNewDot (isLoadingOnyxValue(tryNewDotMetadata)) evaluates to false even though ONYXKEYS.IS_LOADING_APP was seeded to true.
    3. In shouldHideOldAppRedirect(tryNewDot, isLoadingTryNewDot, ...) (src/libs/TryNewDotUtils.ts#L36-L42), when tryNewDot is undefined and isLoadingTryNewDot is false, isOldAppRedirectBlocked(undefined, ...) returns false, so TroubleshootPage renders "Switch to Expensify Classic" during the openApp() request window.

    I have updated my proposal above with the exact root cause and fix (isLoadingApp / isEmptyObject(tryNewDot) guard in TroubleshootPage.tsx & TryNewDotUtils.ts / preserving ONYXKEYS.NVP_TRY_NEW_DOT).

  18. huult commented on Oct 16, 2026

    @huult
    Contributor

    At 0:12 in the ticket video, I can see QA clicking “Clear Cache and Restart,” which makes the “Switch to Expensify Classic” button appear briefly and allows them to click it. However, the test account used above is not actually eligible to use Classic.

    User B has dismissed: false and isLockedToNewDot: true, which is the default state for a new account. New accounts should not have access to Classic, so not returning to OldDot after clicking “Got it” is likely the expected behavior.

    Therefore, I don't think this is a bug. However, preventing the “Switch to Expensify Classic” button from appearing for accounts that aren't eligible to use Classic is already accepted as out of scope for this ticket, as discussed here: #93358 (comment)

    So, I think we should consider two options:

    1. Close this ticket since it doesn't appear to be a bug.
    2. Separately, we should consider whether to hide the “Switch to Expensify Classic” button or show a skeleton placeholder while the cache is being cleared. CC @trjExpensify for consideration.

    🎀 👀 🎀 c+ reviewed.

  19. melvin-bot commented on Oct 16, 2026

    @melvin-bot

    Triggered auto assignment to @madmax330, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  20. melvin-bot commented on Oct 16, 2026

    @melvin-bot

    ⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.

  21. open5588 commented on Oct 16, 2026

    @open5588

    Contributor details
    Your Expensify account email: open5588@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0109a026dfa4d0a6ea

  22. melvin-bot commented on Oct 16, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  23. madmax330 commented on Oct 16, 2026

    @madmax330
    Contributor

    I think this is too edge case and we can just close, thanks @huult

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions