You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] Account - System back button on 2FA success RHP navigates to Account > Security #105693
BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2
Version Number: 9.5.28-4 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#102482 Email or phone of affected tester (no customers):biruknew45+46cb@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Web, android App Component: User Settings
Action Performed:
Preconditions:
Account A owns a workspace that requires 2FA (e.g. Xero connected). Account B already finished onboarding and has 2FA disabled.
As Account A, invite Account B to the workspace as an Admin.
Go to staging.new.expensify.com
Log in as Account B
Click "Enable two-factor authentication"
Complete setup by copying codes and entering the 6-digit code
Press the system back button on the success page
Expected Result:
System back button on 2FA success RHP should lead to Home
Actual Result:
System back button on 2FA success RHP leads to Account > Security instead of Home.
The same happens on web: clicking outside the RHP and browser back button
Three other exits skip that code. Each one pops the whole RHP. That reveals the screen underneath, which is Settings > Security (settings/security?forceSetup=true):
Android back button:goBack reaches only the header arrow. Nothing on the 2FA pages listens for the hardware back button, so react-navigation pops the RHP.
Clicking outside the RHP:handleOverlayPress calls navigation.goBack() on the root stack (RightModalNavigator.tsx:250-268). The 2FA beforeRemove listener there only clears 2FA data (lines 327-334).
Browser back: the previous history entry is settings/security?forceSetup=true, so popstate goes back to it.
What changes do you think we should make in order to solve the problem?
In DynamicSuccessPage, intercept every way of removing the screen during a forced setup, not just the button handlers:
Add a usePreventRemove guard that is on when isForcedSetupFlow || shouldReturnToOnboardingAfter2FA.
When the guard fires, don't replay the original action (that pops to Security). Instead, call the same branch goBack() uses: sendForcedSetupUserHome() or completeForcedOnboarding2FAHandoff().
Turn the guard off (state flag) before those helpers dismiss the modal, so their own dismissal isn't blocked.
Add tests to DynamicSuccessPageTest for the overlay press and the back action. Check that voluntary setup from Settings > Security (no forceSetup) is not guarded.
All three exits fire beforeRemove on the success screen, so one guard covers them. It also fixes the same leak in the incomplete-onboarding handoff, which today can drop the user on Security instead of resuming onboarding.
VacationDelegateMissingWorkspacesPage already uses usePreventRemove this way (index.tsx:95).
What alternative solutions did you explore? (Optional)
useAndroidBackButtonHandler calling goBack(): fixes Android only. The overlay click and browser back stay broken.
Replace Settings > Security with Home under the RHP after verification: fixes the overlay and Android back. It doesn't fix browser back, because the history entry for settings/security?forceSetup=true stays.
Investigation details
I traced this from the code at 82c9505, which includes the PR above. I didn't reproduce it, because that needs a workspace that requires 2FA, such as one with Xero connected.
The setup, verify and success steps replace each other (DynamicVerifyPage.tsx:63). So the success page is the only screen in the 2FA stack, and any back action closes the whole RHP.
Still to confirm: on web, browser back could take react-navigation's resetRoot path instead of goBack. beforeRemove doesn't fire on that path. If it does, browser back needs a separate fix. Check this on web before you finalize the PR.
Home can render behind the RHP at this point because 2FA is already on. sendForcedSetupUserHome already reveals Home from the same screen.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/105693) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
changed the title [-]Account - System back button on 2FA success RHP navigates to Account > Security[/-][+][$175] Account - System back button on 2FA success RHP navigates to Account > Security[/+]on Nov 2, 2026
Root cause: the 2FA success screen sits in the RHP stack on top of Account > Security, so a system back press (Android) or browser back / click-outside (web) simply pops one level to Security instead of exiting the flow — but the expected landing after a completed 2FA setup is Home.
Fix: make the success screen replace the Security entry in the navigation history (or dismiss the whole RHP stack on back), so pressing back from the success screen lands on Home rather than stepping back into Security.
I will verify: on Android system back, web browser back, and clicking outside the RHP, the success screen exits to Home; and Settings > Account > Security remains reachable normally afterwards.
In PR #102482, sendForcedSetupUserHome() was hooked up exclusively to the explicit on-screen button handlers in DynamicSuccessPage.tsx:90-127: the header back arrow (goBack) and the primary "Got it" button (onButtonPress).
DynamicSuccessPage does not intercept stack removal events. Consequently, when a user exits via:
Android hardware / system back button,
Clicking the modal backdrop overlay outside the RHP on web (handleOverlayPress in RightModalNavigator.tsx:250),
Browser back button (popstate), or
Keyboard Escape key,
React Navigation directly pops the RightModalNavigator off the root navigation stack. Because the forced 2FA flow was opened on top of settings/security?forceSetup=true (RequireTwoFactorAuthenticationOverlay.tsx:116-119), popping the RHP directly reveals Account > Security underneath rather than navigating to Home.
isForcedSetupFlow is coupled to isSecuritySettingsFlow (dynamically derived from getStateFromPath(dynamicBackPath)). Once Navigation.revealRouteBeforeDismissingModal(ROUTES.HOME) replaces the fullscreen route underneath the RHP with HOME, isSecuritySettingsFlow evaluates to false during the dismissal animation. The forced setup status must be derived authoritatively from route.params?.forceSetup === 'true'.
(Note: MelvinBot's attempted PR #106178 failed because it used usePreventRemove with a deferred useEffect state toggle, which caused race conditions and blank-page lockups on web when popstate had already altered the browser history stack, and lacked action-type discrimination for DISMISS_MODAL).
What changes do you think we should make in order to solve the problem?
1. Derive isForcedSetup directly from screen route params
In src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx:
Decouple the forced-setup check from the underlying route so it remains stable throughout the entire lifecycle of the screen:
2. Intercept Screen Removal via a beforeRemove Navigation Listener
In DynamicSuccessPage.tsx, register a beforeRemove listener on navigation active during forced setup (isForcedSetup || shouldReturnToOnboardingAfter2FA):
Use an isExitingRef to prevent re-entrant duplicate triggers from rapid clicks.
Call the existing goBack(), which cleanly executes sendForcedSetupUserHome() (or completeForcedOnboarding2FAHandoff()).
Allow the final dismiss action through:
When sendForcedSetupUserHome() executes, it calls Navigation.revealRouteBeforeDismissingModal(ROUTES.HOME), which dispatches CONST.NAVIGATION.ACTION_TYPE.DISMISS_MODAL.
When e.data.action.type === CONST.NAVIGATION.ACTION_TYPE.DISMISS_MODAL, allow the action to proceed unimpeded so the RHP slides out smoothly over Home.
constisExitingRef=useRef(false);useEffect(()=>{if(!isForcedSetup&&!shouldReturnToOnboardingAfter2FA){return;}constunsubscribe=navigation.addListener('beforeRemove',(e)=>{// Allow the intentional DISMISS_MODAL dispatched by revealRouteBeforeDismissingModal throughif(e.data.action.type===CONST.NAVIGATION.ACTION_TYPE.DISMISS_MODAL){return;}e.preventDefault();if(isExitingRef.current){return;}isExitingRef.current=true;goBack();});returnunsubscribe;},[isForcedSetup,shouldReturnToOnboardingAfter2FA,navigation,goBack]);
3. Preserve Voluntary 2FA Setup
When a user sets up 2FA voluntarily from Settings > Security (without forceSetup=true):
isForcedSetup is false.
The beforeRemove listener is not attached, and voluntary setups preserve their existing behavior (navigating to ROUTES.SETTINGS_2FA_ENABLED via onButtonPress).
4. Before and After Results
Before (on main):
Completing forced 2FA setup lands on 2FA Success page.
Pressing Android system back, clicking outside the modal overlay, or pressing browser back pops the RHP directly, dropping the user back to Account > Security (/settings/security):
Completing forced 2FA setup lands on 2FA Success page.
Pressing Android system back, clicking outside the modal overlay, or pressing browser back is intercepted by the beforeRemove listener, executing sendForcedSetupUserHome(), smoothly dismissing the RHP, and landing the user on Home (/home) with zero blank pages:
Screenshot of expected outcome (lands on Home):
Verification Matrix
Expected Result
Actual Result with Fix
Android Hardware Back Button
Navigate to Home (/home)
✅ Lands on Home
Modal Backdrop Overlay Click (Web)
Navigate to Home (/home)
✅ Lands on Home
Browser Back Button (Web)
Navigate to Home (/home)
✅ Lands on Home
Keyboard Escape Key
Navigate to Home (/home)
✅ Lands on Home
Voluntary 2FA Setup (from Settings)
Keep on Enabled Page (SETTINGS_2FA_ENABLED)
✅ Stays on Enabled Page
Incomplete Onboarding Forced 2FA
Resume Onboarding Handoff
✅ Resumes Onboarding
5. Automated Tests
In tests/unit/pages/settings/Security/TwoFactorAuth/DynamicSuccessPageTest.tsx:
Add test asserting that dismissing the RHP via Android system back or overlay click when forceSetup === 'true' navigates to ROUTES.HOME.
Add test asserting that dismissing the RHP when shouldReturnToOnboardingAfter2FA === true executes the onboarding handoff (resumeOnboardingAfterRequired2FASetup).
Add test verifying that voluntary 2FA setup (forceSetup=undefined) does not intercept dismissal and navigates to SETTINGS_2FA_ENABLED.
What alternative solutions did you explore? (Optional)
useAndroidBackButtonHandler: Only intercepts the Android hardware back button; leaves modal backdrop clicks, keyboard Escape, and web browser back still revealing Settings > Security.
usePreventRemove with state toggling in useEffect (PR Route forced two-factor success dismissals to Home #106178): Causes race conditions on web when browser popstate has already altered history, leading to blank page freezes and broken second-back navigation.
Modifying handleOverlayPress in RightModalNavigator: Pollutes global modal navigation with two-factor-specific route checks and does not solve Android hardware back or browser back.
Please re-state the problem that we are trying to solve in this issue.
In a forced 2FA setup flow (e.g. an invited admin to a workspace that requires 2FA), completing the setup opens the 2FA Success page. Pressing the Android hardware/system back button, clicking outside the Right Hand Pane (RHP) overlay on web, or pressing the browser back button navigates the user to Account > Security (settings/security?forceSetup=true) instead of navigating them to Home.
What is the root cause of that problem?
In src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx (lines 90-127): sendForcedSetupUserHome() is only hooked up to the header back button (onBackButtonPress={goBack}) and the primary "Got it" button (onButtonPress).
When a user:
Presses the Android hardware back button,
Clicks outside the RHP modal overlay (triggering handleOverlayPress in RightModalNavigator.tsx), or
Uses the browser back button,
the dismissal bypasses goBack() and executes directly on the root/modal stack navigator. Because the 2FA flow was initiated from settings/security?forceSetup=true, popping the RHP reveals Settings > Security underneath rather than returning the user to Home.
What changes do you think we should make in order to solve the problem?
In src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx:
Import usePreventRemove from @react-navigation/native and useRef from react.
Add a usePreventRemove guard active when (isForcedSetupFlow || shouldReturnToOnboardingAfter2FA).
Use a isDismissingRef flag to prevent blocking our custom dismissal:
--- a/src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx+++ b/src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx@@ -29,8 +29,8 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import {hasCompletedGuidedSetupFlowSelector} from '@src/selectors/Onboarding';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
-import {findFocusedRoute} from '@react-navigation/native';+import {findFocusedRoute, usePreventRemove} from '@react-navigation/native';
import {authTokenTypeSelector} from '@selectors/Session';
-import React from 'react';+import React, {useRef} from 'react';
import SuccessPageBase from './SuccessPageBase';
@@ -53,4 +53,12 @@ function DynamicSuccessPage({route}: DynamicSuccessPageProps) {
const isForcedSetupFlow = isSecuritySettingsFlow && route.params?.forceSetup === 'true';
+ const isDismissingRef = useRef(false);+ usePreventRemove(+ (isForcedSetupFlow || shouldReturnToOnboardingAfter2FA) && !isDismissingRef.current,+ () => {+ isDismissingRef.current = true;+ goBack();+ },+ );
When beforeRemove is intercepted, goBack() is triggered, properly executing sendForcedSetupUserHome() or completeForcedOnboarding2FAHandoff() to navigate the user to Home.
What alternative solutions did you explore? (Optional)
Using useAndroidBackButtonHandler: This only handles Android hardware back and leaves click-outside-overlay and browser back still falling back to Settings > Security. usePreventRemove intercepts all screen removal actions uniformly.
What automated tests can you add to prevent this from re-occurring?
In tests/unit/DynamicSuccessPageTest.tsx:
Verify that when isForcedSetupFlow === true, triggering a beforeRemove event on the navigation container executes sendForcedSetupUserHome().
Verify that voluntary 2FA setup from Settings > Security (isForcedSetupFlow === false) is not intercepted.
Contributor Track Record & Details
Proven Open-Source Contributor: Successfully merged pull requests in major enterprise repositories including Microsoft .NET runtime (PR reference: dotnet/runtime#136828).
Ready for Fast Turnaround: Full environment configured, ready to push clean PR with passing Jest tests immediately upon assignment.
Please re-state the problem that we are trying to solve in this issue.
In a forced 2FA setup flow (e.g., an invited admin to a workspace that requires 2FA), completing 2FA displays the success page. Pressing the Android hardware/system back button, clicking the web modal backdrop overlay outside the RHP, or using the browser back button lands the user on Account > Security (settings/security?forceSetup=true) instead of navigating them to Home.
What is the root cause of that problem?
In src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx:
sendForcedSetupUserHome() (or the custom forced-setup dismissal) is only wired up to the explicit UI buttons: the header back arrow (onBackButtonPress={goBack}) and the primary button (onButtonPress).
When the user:
Presses the Android hardware back button,
Clicks outside the RHP modal overlay (triggering handleOverlayPress in RightModalNavigator.tsx), or
Presses the browser back button,
the navigation dismissal bypasses goBack() and executes directly on the root/modal navigator stack.
Because the 2FA flow was launched on top of settings/security?forceSetup=true, popping the RHP reveals Settings > Security underneath rather than returning the user to Home.
What changes do you think we should make in order to solve the problem?
In src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx:
Import usePreventRemove from @react-navigation/native and useRef from react.
Add a usePreventRemove hook active when (isForcedSetupFlow || shouldReturnToOnboardingAfter2FA):
When beforeRemove is intercepted, goBack() is triggered. goBack() routes through sendForcedSetupUserHome() (or completeForcedOnboarding2FAHandoff()), which properly navigates the user to Home (or resumes onboarding) before dismissing the modal. The isDismissingRef guard ensures that the subsequent programmatic dismissal is not blocked.
What alternative solutions did you explore? (Optional)
useAndroidBackButtonHandler: Explored, but rejected because it only handles Android hardware back events and leaves web backdrop clicks and browser back actions unhandled. usePreventRemove cleanly intercepts all removal vectors uniformly across all platforms.
What automated tests can you add to prevent this from re-occurring?
In tests/unit/DynamicSuccessPageTest.tsx:
Add a test verifying that when isForcedSetupFlow is true, dispatching a beforeRemove navigation event executes sendForcedSetupUserHome().
Add a test verifying that when voluntary 2FA is set up from Settings > Security (isForcedSetupFlow === false), beforeRemove is not intercepted.
@daledah@MariaHCD before assignment, one start where the selected proposal still lands on Account > Security: the required-2FA overlay used while the Settings tab is open (for example, the app reopened on an Account page). The setup then opens over that Settings page without forceSetup, so the success page doesn't treat it as forced, and neither browser back nor Got it sends the user Home.
I applied the selected proposal's code as written (the replaceFullscreenUnderRHP helper and the useBeforeRemove listener) on main, and ran it locally with a real 2FA setup (the overlay shown by setting needsTwoFactorAuthSetup, as in my proposal):
Start → exit
selected proposal
my proposal
Settings > Security → browser back
Account > Security
Home
Settings > Security → Got it
"2FA enabled" page
Home
Settings > Profile → browser back / Got it
Profile / Profile
Home / Home
E-selected-vs-this-settings-security.webm
My proposal covers this start in part 2: a small helper keeps forceSetup under the setup when it starts inside the Settings tab, so the same exit fix applies there too.
Please re-state the problem that we are trying to solve in this issue.
When an account is required by a workspace policy to enable 2FA (needsTwoFactorAuthSetup / forceSetup=true) and completes the 2FA setup flow to reach DynamicSuccessPage, dismissing the RHP via the Android hardware back button, browser back button, Escape key, or modal backdrop overlay lands the user on Account > Security (or the underlying Settings tab route) instead of navigating to Home.
What is the root cause of that problem?
Explicit button handlers vs. implicit modal dismissal (src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx):
In PR Send users Home after required 2FA setup instead of Settings > Security #102482, DynamicSuccessPage wired the forced-setup redirect (Navigation.revealRouteBeforeDismissingModal(ROUTES.HOME)) only into onButtonPress ("Got it") and onBackButtonPress (the header back button). When the user dismisses the RHP via Android system back, browser back, Escape, or clicking the RHP overlay backdrop, React Navigation dispatches POP / GO_BACK on the modal navigator directly without invoking onBackButtonPress, revealing SettingsSplitNavigator (Account > Security) underneath.
Asynchronous frame gap in revealRouteBeforeDismissingModal on browser Back + missing forceSetup when started from the required-2FA overlay on a Settings tab:
Calling revealRouteBeforeDismissingModal(ROUTES.HOME) as-is inside a beforeRemove handler defers the underlying fullscreen replacement to requestAnimationFrame, racing with browser history pop (POP) on Web.
Additionally, if the user opens/reloads the app while already on a Settings tab route (Account > Security or Account > Profile), the required-2FA overlay opens the 2FA RHP over that Settings screen without forceSetup=true in the route params, so DynamicSuccessPage does not recognize the flow as a forced 2FA setup and leaves the user on Account > Security.
What changes do you think we should make in order to solve the problem?
Propagate forceSetup whenever the 2FA flow is launched from the required-2FA overlay (RequireTwoFactorAuthOverlay / TwoFactorAuthSteps):
Ensure forceSetup: 'true' is passed in the route params (or derived when the flow was initiated while needsTwoFactorAuthSetup was active) regardless of whether the underlying fullscreen route was HOME or SETTINGS.
Handle non-button dismissal synchronously in DynamicSuccessPage.tsx:
Add a useBeforeRemove (or navigation.addListener('beforeRemove', ...)) guard on DynamicSuccessPage when isForcedSetup is true (and not already handled by the explicit button press):
Replace the underlying fullscreen route with ROUTES.HOME synchronously in the same navigation dispatch / before modal removal completes (replaceFullscreenUnderRHP(ROUTES.HOME) / shouldRevealImmediately: true in revealRouteBeforeDismissingModal), so Android hardware back, backdrop click, Escape, and browser back all land cleanly on ROUTES.HOME without flashing Account > Security.
What alternative solutions did you explore? (Optional)
Intercepting only BackHandler on Android was ruled out because it does not cover Web browser back, Escape, or clicking outside the RHP backdrop overlay.
Please re-state the problem that we are trying to solve in this issue.
When a user is required to set up 2FA from RequireTwoFactorAuthenticationOverlay and reaches the 2FA success RHP (DynamicSuccessPage), only Got it and the header back arrow navigate to Home (or resume incomplete onboarding). Dismissing the RHP via the Android system back button, Web browser back button, Escape key, or clicking outside the RHP lands on Account > Security (or the previously open Settings/RHP route) instead of Home.
What is the root cause of that problem?
There are two root defects in how PR #102482 wired forced-setup routing and modal exit:
Non-button dismissals bypass DynamicSuccessPage's exit helpers, and deferred or unprevented removals desync useLinking / RightModalNavigator:
In DynamicSuccessPage.tsx#L72-L138, sendForcedSetupUserHome() and completeForcedOnboarding2FAHandoff() are only wired to onBackButtonPress (goBack) and onButtonPress.
Android hardware back, backdrop clicks (RightModalNavigator.tsx#L273-L291), Escape (DISMISS_MODAL), and browser back (popstate dispatching GO_BACK or RESET) remove the modal directly, exposing Settings > Security underneath.
Calling e.preventDefault() and deferring the swap to requestAnimationFrame via revealRouteBeforeDismissingModal (#106178, Navigation.ts#L1231-L1283) leaves root state unchanged during popstate, so useLinking runs rollbackHistory() (history.go(+1)) and races the rAF swap into a blank page. Conversely, swapping without e.preventDefault() fails on CommonActions.reset (rapid browser back overwrites Home back to Security), only pops one screen inside RightModalNavigator if another RHP was stacked underneath, and leaves an unconsumed pendingReveal in addRootHistoryRouterExtension.ts#L77-L101. Even swapping Home synchronously while keeping DISMISS_MODAL on rAF with a frozen pendingReveal (addRootHistoryRouterExtensionUtils.ts#L124) yields historyDelta = 2 - 2 - (-1) = +1 in useLinking on browser back, pushing a new history entry and leaving /settings/security at index - 1.
forceSetup is attached to ROUTES.SETTINGS_SECURITY instead of DYNAMIC_ROUTES.TWO_FACTOR_AUTH_*, dropping forceSetup on Settings/RHP starts and polluting Settings_Security afterward:
When the overlay opens while SETTINGS_SPLIT_NAVIGATOR is already active (linkTo/index.ts#L145-L158) or while any RHP is already open (linkTo/index.ts#L261), linkTo does not place Settings_Security?forceSetup=true underneath. Step 1 → Step 2 rebuilds its URL from backPath without forceSetup, and DynamicSuccessPage.tsx#L46-L49 also gates isForcedSetupFlow and shouldReturnToOnboardingAfter2FA (#L68) on isSecuritySettingsFlow.
Conversely, when Settings_Securitydoes receive params: {forceSetup: 'true'}, GetStateForActionHandlers.ts#L366-L373 preserves non-target tab state on Home reveal, leaving ?forceSetup=true on Settings_Security so a later voluntary setup from SecuritySettingsPage.tsx#L114 (getTwoFactorAuthRoute() resolving getActiveRoute() at createDynamicRoute.ts#L83) inherits forceSetup=true.
What changes do you think we should make in order to solve the problem?
Move forceSetup ownership onto DYNAMIC_ROUTES.TWO_FACTOR_AUTH_* (src/ROUTES.ts, src/hooks/useTwoFactorAuthRoute.ts, src/libs/Navigation/types.ts, RequireTwoFactorAuthenticationOverlay.tsx, and the 2FA dynamic step pages):
Declare getRoute and queryParams: ['forceSetup'] on the four TWO_FACTOR_AUTH_* entries in src/ROUTES.ts (matching VERIFY_ACCOUNT / ADD_BANK_ACCOUNT_VERIFY_ACCOUNT), so getPathFromState preserves forceSetup=true on the active 2FA route while getPathWithoutDynamicSuffix automatically strips forceSetup from backPath:
TWO_FACTOR_AUTH_ROOT: {path: 'two-factor-auth',entryScreens: ['*'],getRoute: (options?: {forceSetup?: boolean})=>getUrlWithParams('two-factor-auth',{forceSetup: options?.forceSetup ? 'true' : undefined}),queryParams: ['forceSetup'],},// Same getRoute + queryParams: ['forceSetup'] on TWO_FACTOR_AUTH_VERIFY_ACCOUNT, TWO_FACTOR_AUTH_VERIFY, and TWO_FACTOR_AUTH_SUCCESS
In useTwoFactorAuthRoute.ts, build the suffix with DYNAMIC_ROUTES.TWO_FACTOR_AUTH_VERIFY_ACCOUNT.getRoute(options) and DYNAMIC_ROUTES.TWO_FACTOR_AUTH_ROOT.getRoute(options), and in RequireTwoFactorAuthenticationOverlay.tsx#L118 pass clean ROUTES.SETTINGS_SECURITY.getRoute() with {forceSetup: true} (removing the forceSetup param from ROUTES.SETTINGS_SECURITY.getRoute so Settings_Security is never polluted).
Type {forceSetup?: string} on DYNAMIC_ROOT, DYNAMIC_VERIFY_ACCOUNT, and DYNAMIC_VERIFY in TwoFactorAuthNavigatorParamList, and forward {forceSetup: route.params?.forceSetup === 'true'} in the intra-flow DYNAMIC_ROUTES.TWO_FACTOR_AUTH_*.getRoute(...) transitions in DynamicTwoFactorAuthVerifyAccountPage.tsx, DynamicTwoFactorAuthPage.tsx, and DynamicVerifyPage.tsx.
Add a single-turn synchronous modal-dismiss-to-route helper for removal events (Navigation.ts, createRootStackNavigator/types.ts, addRootHistoryRouterExtension.ts):
Add shouldFreezeHistory?: boolean (default true) to REPLACE_FULLSCREEN_UNDER_RHP so addRootHistoryRouterExtension.ts#L77 skips getFrozenHistoryStateForReplaceFullscreenUnderRHP when action.payload.shouldFreezeHistory === false.
Expose Navigation.dismissModalToRoute(route, {afterTransition}) in src/libs/Navigation/Navigation.ts, which synchronously dispatches REPLACE_FULLSCREEN_UNDER_RHP (shouldFreezeHistory: false) followed immediately by dismissModal({afterTransition}) in the same turn:
Because both dispatches commit synchronously inside beforeRemove, root state becomes [Tab(Home)] (history.length = 1) in the same turn: useLinking sees afterState !== beforeState (no rollbackHistory()), single browser back (pendingPopStateDelta = -1) computes historyDelta = 1 - 2 - (-1) = 0 and history.replaces /settings/security in place with /home, backdrop/Escape (pendingPopStateDelta = null) pops the modal entry and replaces /settings/security with /home, RESET cannot overwrite Home, and DISMISS_MODAL closes the entire RightModalNavigator even if another RHP was open underneath.
Decouple forced flags from isSecuritySettingsFlow and intercept non-button removals in DynamicSuccessPage.tsx:
Set const isForcedSetupFlow = route.params?.forceSetup === 'true'; and const shouldReturnToOnboardingAfter2FA = (isSecuritySettingsFlow || isForcedSetupFlow) && isForcedOnboardingHandoff;.
Guard explicit and implicit exits with isExitingForcedSetupRef and useBeforeRemove (src/hooks/useBeforeRemove.tsx):
Set isExitingForcedSetupRef.current = true at the start of completeForcedOnboarding2FAHandoff and sendForcedSetupUserHome so Got it and the header back arrow keep their existing two-frame revealRouteBeforeDismissingModal transition unimpeded, while voluntary Settings, USD bank account, and Xero 2FA flows remain untouched.
What alternative solutions did you explore? (Optional)
Mutating or pre-navigating Settings_Security?forceSetup=true from RequireTwoFactorAuthenticationOverlay when on the Settings tab: Still fails when an RHP is already open (linkTo skips fullscreen matching whenever RIGHT_MODAL_NAVIGATOR is on top) and leaves forceSetup: 'true' persisted on Settings_Security in SETTINGS_SPLIT_NAVIGATOR for subsequent voluntary setups in the same session.
Dispatching REPLACE_FULLSCREEN_UNDER_RHP on DynamicSuccessPage mount (preInsertFullscreenUnderRHP) or inside beforeRemove without e.preventDefault(): Mount-time pre-insertion freezes history via pendingReveal and disables RHP slide animations; skipping e.preventDefault() breaks on CommonActions.reset (rapid browser back), leaks pendingReveal, and only pops one inner screen when another RHP was stacked below TwoFactorAuth.
The steps in the issue start from login. On staging, Got it on that success screen already goes Home. Back is what still lands on Account > Security, and that is what the selected proposal fixes.
Your video starts with the Settings tab already open, so the setup opens over that Account page and forceSetup never reaches the success screen. That is why Got it stays on the Enabled page and back stays on Security or Profile. I can cover that start in the PR if we want it in this issue. Thanks!!
@MariaHCD Waiting for the assignment here, thanks!!
📣 @neerajbachani You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖
BugSomething is broken. Auto assigns a BugZero manager.ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in reviewWeeklyKSv2
Activity
applause-bot commentedon Nov 2, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/0323890c7b8f9b71e5c692c5b53012715a0b3cdd0f914c900e519f014e9071d9
MelvinBot commentedon Nov 2, 2026
Proposal
What is the root cause of that problem?
Send users Home after required 2FA setup instead of Settings > Security only redirects two exits on the success page: Got it and the header back arrow. Both call
sendForcedSetupUserHome()inDynamicSuccessPage.tsx:90-127.Three other exits skip that code. Each one pops the whole RHP. That reveals the screen underneath, which is Settings > Security (
settings/security?forceSetup=true):goBackreaches only the header arrow. Nothing on the 2FA pages listens for the hardware back button, so react-navigation pops the RHP.handleOverlayPresscallsnavigation.goBack()on the root stack (RightModalNavigator.tsx:250-268). The 2FAbeforeRemovelistener there only clears 2FA data (lines 327-334).settings/security?forceSetup=true, so popstate goes back to it.What changes do you think we should make in order to solve the problem?
In
DynamicSuccessPage, intercept every way of removing the screen during a forced setup, not just the button handlers:usePreventRemoveguard that is on whenisForcedSetupFlow || shouldReturnToOnboardingAfter2FA.goBack()uses:sendForcedSetupUserHome()orcompleteForcedOnboarding2FAHandoff().DynamicSuccessPageTestfor the overlay press and the back action. Check that voluntary setup from Settings > Security (noforceSetup) is not guarded.All three exits fire
beforeRemoveon the success screen, so one guard covers them. It also fixes the same leak in the incomplete-onboarding handoff, which today can drop the user on Security instead of resuming onboarding.VacationDelegateMissingWorkspacesPagealready usesusePreventRemovethis way (index.tsx:95).What alternative solutions did you explore? (Optional)
useAndroidBackButtonHandlercallinggoBack(): fixes Android only. The overlay click and browser back stay broken.settings/security?forceSetup=truestays.Investigation details
82c9505, which includes the PR above. I didn't reproduce it, because that needs a workspace that requires 2FA, such as one with Xero connected.DynamicVerifyPage.tsx:63). So the success page is the only screen in the 2FA stack, and any back action closes the whole RHP.resetRootpath instead ofgoBack.beforeRemovedoesn't fire on that path. If it does, browser back needs a separate fix. Check this on web before you finalize the PR.sendForcedSetupUserHomealready reveals Home from the same screen.Related issues:
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/105693)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
melvin-bot commentedon Nov 2, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @daledah (
External)[-]Account - System back button on 2FA success RHP navigates to Account > Security[/-][+][$175] Account - System back button on 2FA success RHP navigates to Account > Security[/+]melvin-bot commentedon Nov 2, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
khizzcr7 commentedon Nov 3, 2026
Root cause: the 2FA success screen sits in the RHP stack on top of Account > Security, so a system back press (Android) or browser back / click-outside (web) simply pops one level to Security instead of exiting the flow — but the expected landing after a completed 2FA setup is Home.
Fix: make the success screen replace the Security entry in the navigation history (or dismiss the whole RHP stack on back), so pressing back from the success screen lands on Home rather than stepping back into Security.
I will verify: on Android system back, web browser back, and clicking outside the RHP, the success screen exits to Home; and Settings > Account > Security remains reachable normally afterwards.
kevinjosh10 commentedon Nov 3, 2026
Proposal
What is the root cause of that problem?
In PR #102482,
sendForcedSetupUserHome()was hooked up exclusively to the explicit on-screen button handlers inDynamicSuccessPage.tsx:90-127: the header back arrow (goBack) and the primary "Got it" button (onButtonPress).DynamicSuccessPagedoes not intercept stack removal events. Consequently, when a user exits via:handleOverlayPressinRightModalNavigator.tsx:250),popstate), orReact Navigation directly pops the
RightModalNavigatoroff the root navigation stack. Because the forced 2FA flow was opened on top ofsettings/security?forceSetup=true(RequireTwoFactorAuthenticationOverlay.tsx:116-119), popping the RHP directly reveals Account > Security underneath rather than navigating to Home.Furthermore, in
DynamicSuccessPage.tsx:isForcedSetupFlowis coupled toisSecuritySettingsFlow(dynamically derived fromgetStateFromPath(dynamicBackPath)). OnceNavigation.revealRouteBeforeDismissingModal(ROUTES.HOME)replaces the fullscreen route underneath the RHP withHOME,isSecuritySettingsFlowevaluates tofalseduring the dismissal animation. The forced setup status must be derived authoritatively fromroute.params?.forceSetup === 'true'.(Note: MelvinBot's attempted PR #106178 failed because it used
usePreventRemovewith a deferreduseEffectstate toggle, which caused race conditions and blank-page lockups on web whenpopstatehad already altered the browser history stack, and lacked action-type discrimination forDISMISS_MODAL).What changes do you think we should make in order to solve the problem?
1. Derive
isForcedSetupdirectly from screen route paramsIn
src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx:2. Intercept Screen Removal via a
beforeRemoveNavigation ListenerIn
DynamicSuccessPage.tsx, register abeforeRemovelistener onnavigationactive during forced setup (isForcedSetup || shouldReturnToOnboardingAfter2FA):e.preventDefault()).isExitingRefto prevent re-entrant duplicate triggers from rapid clicks.goBack(), which cleanly executessendForcedSetupUserHome()(orcompleteForcedOnboarding2FAHandoff()).sendForcedSetupUserHome()executes, it callsNavigation.revealRouteBeforeDismissingModal(ROUTES.HOME), which dispatchesCONST.NAVIGATION.ACTION_TYPE.DISMISS_MODAL.e.data.action.type === CONST.NAVIGATION.ACTION_TYPE.DISMISS_MODAL, allow the action to proceed unimpeded so the RHP slides out smoothly over Home.3. Preserve Voluntary 2FA Setup
When a user sets up 2FA voluntarily from
Settings > Security(withoutforceSetup=true):isForcedSetupisfalse.beforeRemovelistener is not attached, and voluntary setups preserve their existing behavior (navigating toROUTES.SETTINGS_2FA_ENABLEDviaonButtonPress).4. Before and After Results
Before (on
main):/settings/security):After (with our fix):
beforeRemovelistener, executingsendForcedSetupUserHome(), smoothly dismissing the RHP, and landing the user on Home (/home) with zero blank pages:/home)/home)/home)/home)SETTINGS_2FA_ENABLED)5. Automated Tests
In
tests/unit/pages/settings/Security/TwoFactorAuth/DynamicSuccessPageTest.tsx:forceSetup === 'true'navigates toROUTES.HOME.shouldReturnToOnboardingAfter2FA === trueexecutes the onboarding handoff (resumeOnboardingAfterRequired2FASetup).forceSetup=undefined) does not intercept dismissal and navigates toSETTINGS_2FA_ENABLED.What alternative solutions did you explore? (Optional)
useAndroidBackButtonHandler: Only intercepts the Android hardware back button; leaves modal backdrop clicks, keyboard Escape, and web browser back still revealingSettings > Security.usePreventRemovewith state toggling inuseEffect(PR Route forced two-factor success dismissals to Home #106178): Causes race conditions on web when browserpopstatehas already altered history, leading to blank page freezes and broken second-back navigation.handleOverlayPressinRightModalNavigator: Pollutes global modal navigation with two-factor-specific route checks and does not solve Android hardware back or browser back.Contributor details
Your Expensify account email: lkevinjosh10@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
sumit-2007-git commentedon Nov 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In a forced 2FA setup flow (e.g. an invited admin to a workspace that requires 2FA), completing the setup opens the 2FA Success page. Pressing the Android hardware/system back button, clicking outside the Right Hand Pane (RHP) overlay on web, or pressing the browser back button navigates the user to Account > Security (
settings/security?forceSetup=true) instead of navigating them to Home.What is the root cause of that problem?
In
src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx(lines 90-127):sendForcedSetupUserHome()is only hooked up to the header back button (onBackButtonPress={goBack}) and the primary "Got it" button (onButtonPress).When a user:
handleOverlayPressinRightModalNavigator.tsx), orthe dismissal bypasses
goBack()and executes directly on the root/modal stack navigator. Because the 2FA flow was initiated fromsettings/security?forceSetup=true, popping the RHP revealsSettings > Securityunderneath rather than returning the user to Home.What changes do you think we should make in order to solve the problem?
In
src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx:usePreventRemovefrom@react-navigation/nativeanduseReffromreact.usePreventRemoveguard active when(isForcedSetupFlow || shouldReturnToOnboardingAfter2FA).isDismissingRefflag to prevent blocking our custom dismissal:When
beforeRemoveis intercepted,goBack()is triggered, properly executingsendForcedSetupUserHome()orcompleteForcedOnboarding2FAHandoff()to navigate the user to Home.What alternative solutions did you explore? (Optional)
useAndroidBackButtonHandler: This only handles Android hardware back and leaves click-outside-overlay and browser back still falling back toSettings > Security.usePreventRemoveintercepts all screen removal actions uniformly.What automated tests can you add to prevent this from re-occurring?
In
tests/unit/DynamicSuccessPageTest.tsx:isForcedSetupFlow === true, triggering abeforeRemoveevent on the navigation container executessendForcedSetupUserHome().isForcedSetupFlow === false) is not intercepted.Contributor Track Record & Details
ayolyn commentedon Nov 3, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In a forced 2FA setup flow (e.g., an invited admin to a workspace that requires 2FA), completing 2FA displays the success page. Pressing the Android hardware/system back button, clicking the web modal backdrop overlay outside the RHP, or using the browser back button lands the user on Account > Security (
settings/security?forceSetup=true) instead of navigating them to Home.What is the root cause of that problem?
In
src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx:sendForcedSetupUserHome()(or the custom forced-setup dismissal) is only wired up to the explicit UI buttons: the header back arrow (onBackButtonPress={goBack}) and the primary button (onButtonPress).handleOverlayPressinRightModalNavigator.tsx), orthe navigation dismissal bypasses
goBack()and executes directly on the root/modal navigator stack.settings/security?forceSetup=true, popping the RHP revealsSettings > Securityunderneath rather than returning the user to Home.What changes do you think we should make in order to solve the problem?
In
src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx:usePreventRemovefrom@react-navigation/nativeanduseReffromreact.usePreventRemovehook active when(isForcedSetupFlow || shouldReturnToOnboardingAfter2FA):beforeRemoveis intercepted,goBack()is triggered.goBack()routes throughsendForcedSetupUserHome()(orcompleteForcedOnboarding2FAHandoff()), which properly navigates the user to Home (or resumes onboarding) before dismissing the modal. TheisDismissingRefguard ensures that the subsequent programmatic dismissal is not blocked.What alternative solutions did you explore? (Optional)
useAndroidBackButtonHandler: Explored, but rejected because it only handles Android hardware back events and leaves web backdrop clicks and browser back actions unhandled.usePreventRemovecleanly intercepts all removal vectors uniformly across all platforms.What automated tests can you add to prevent this from re-occurring?
In
tests/unit/DynamicSuccessPageTest.tsx:isForcedSetupFlowistrue, dispatching abeforeRemovenavigation event executessendForcedSetupUserHome().isForcedSetupFlow === false),beforeRemoveis not intercepted.Contributor details
Your Expensify account email: juliusayolyn@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0105126232377c4c5c
melvin-bot commentedon Nov 3, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
67 remaining items
laveshfonix commentedon Nov 12, 2026
@daledah @MariaHCD before assignment, one start where the selected proposal still lands on Account > Security: the required-2FA overlay used while the Settings tab is open (for example, the app reopened on an Account page). The setup then opens over that Settings page without
forceSetup, so the success page doesn't treat it as forced, and neither browser back nor Got it sends the user Home.I applied the selected proposal's code as written (the
replaceFullscreenUnderRHPhelper and theuseBeforeRemovelistener) on main, and ran it locally with a real 2FA setup (the overlay shown by settingneedsTwoFactorAuthSetup, as in my proposal):E-selected-vs-this-settings-security.webm
My proposal covers this start in part 2: a small helper keeps
forceSetupunder the setup when it starts inside the Settings tab, so the same exit fix applies there too.bonnhatnguyen commentedon Nov 12, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When an account is required by a workspace policy to enable 2FA (
needsTwoFactorAuthSetup/forceSetup=true) and completes the 2FA setup flow to reachDynamicSuccessPage, dismissing the RHP via the Android hardware back button, browser back button, Escape key, or modal backdrop overlay lands the user on Account > Security (or the underlying Settings tab route) instead of navigating to Home.What is the root cause of that problem?
src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx):In PR Send users Home after required 2FA setup instead of Settings > Security #102482,
DynamicSuccessPagewired the forced-setup redirect (Navigation.revealRouteBeforeDismissingModal(ROUTES.HOME)) only intoonButtonPress("Got it") andonBackButtonPress(the header back button). When the user dismisses the RHP via Android system back, browser back, Escape, or clicking the RHP overlay backdrop, React Navigation dispatchesPOP/GO_BACKon the modal navigator directly without invokingonBackButtonPress, revealingSettingsSplitNavigator(Account > Security) underneath.revealRouteBeforeDismissingModalon browser Back + missingforceSetupwhen started from the required-2FA overlay on a Settings tab:revealRouteBeforeDismissingModal(ROUTES.HOME)as-is inside abeforeRemovehandler defers the underlying fullscreen replacement torequestAnimationFrame, racing with browser history pop (POP) on Web.Settingstab route (Account > SecurityorAccount > Profile), the required-2FA overlay opens the 2FA RHP over that Settings screen withoutforceSetup=truein the route params, soDynamicSuccessPagedoes not recognize the flow as a forced 2FA setup and leaves the user onAccount > Security.What changes do you think we should make in order to solve the problem?
forceSetupwhenever the 2FA flow is launched from the required-2FA overlay (RequireTwoFactorAuthOverlay/TwoFactorAuthSteps):Ensure
forceSetup: 'true'is passed in the route params (or derived when the flow was initiated whileneedsTwoFactorAuthSetupwas active) regardless of whether the underlying fullscreen route wasHOMEorSETTINGS.DynamicSuccessPage.tsx:Add a
useBeforeRemove(ornavigation.addListener('beforeRemove', ...)) guard onDynamicSuccessPagewhenisForcedSetupis true (and not already handled by the explicit button press):ROUTES.HOMEsynchronously in the same navigation dispatch / before modal removal completes (replaceFullscreenUnderRHP(ROUTES.HOME)/shouldRevealImmediately: trueinrevealRouteBeforeDismissingModal), so Android hardware back, backdrop click, Escape, and browser back all land cleanly onROUTES.HOMEwithout flashingAccount > Security.What alternative solutions did you explore? (Optional)
Intercepting only
BackHandleron Android was ruled out because it does not cover Web browser back, Escape, or clicking outside the RHP backdrop overlay.Contributor details:
ocakciomursel-pixel commentedon Nov 12, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user is required to set up 2FA from
RequireTwoFactorAuthenticationOverlayand reaches the 2FA success RHP (DynamicSuccessPage), only Got it and the header back arrow navigate to Home (or resume incomplete onboarding). Dismissing the RHP via the Android system back button, Web browser back button, Escape key, or clicking outside the RHP lands on Account > Security (or the previously open Settings/RHP route) instead of Home.What is the root cause of that problem?
There are two root defects in how PR #102482 wired forced-setup routing and modal exit:
Non-button dismissals bypass
DynamicSuccessPage's exit helpers, and deferred or unprevented removals desyncuseLinking/RightModalNavigator:DynamicSuccessPage.tsx#L72-L138,sendForcedSetupUserHome()andcompleteForcedOnboarding2FAHandoff()are only wired toonBackButtonPress(goBack) andonButtonPress.RightModalNavigator.tsx#L273-L291), Escape (DISMISS_MODAL), and browser back (popstatedispatchingGO_BACKorRESET) remove the modal directly, exposingSettings > Securityunderneath.e.preventDefault()and deferring the swap torequestAnimationFrameviarevealRouteBeforeDismissingModal(#106178,Navigation.ts#L1231-L1283) leaves root state unchanged duringpopstate, souseLinkingrunsrollbackHistory()(history.go(+1)) and races therAFswap into a blank page. Conversely, swapping withoute.preventDefault()fails onCommonActions.reset(rapid browser back overwritesHomeback toSecurity), only pops one screen insideRightModalNavigatorif another RHP was stacked underneath, and leaves an unconsumedpendingRevealinaddRootHistoryRouterExtension.ts#L77-L101. Even swappingHomesynchronously while keepingDISMISS_MODALonrAFwith a frozenpendingReveal(addRootHistoryRouterExtensionUtils.ts#L124) yieldshistoryDelta = 2 - 2 - (-1) = +1inuseLinkingon browser back, pushing a new history entry and leaving/settings/securityatindex - 1.forceSetupis attached toROUTES.SETTINGS_SECURITYinstead ofDYNAMIC_ROUTES.TWO_FACTOR_AUTH_*, droppingforceSetupon Settings/RHP starts and pollutingSettings_Securityafterward:RequireTwoFactorAuthenticationOverlay.tsx#L118passesROUTES.SETTINGS_SECURITY.getRoute(true)asbackTo, whileDYNAMIC_ROUTES.TWO_FACTOR_AUTH_*declare noqueryParams: ['forceSetup']anduseTwoFactorAuthRoute.ts#L37-L41appends bare suffixes.twoFactorAuthForceSetupDynamicRouteTest.ts#L26-L31passed because it stripped suffixes from strings directly, whereas at runtimeuseDynamicBackPath.ts#L29-L36serializes live navigation state viagetPathFromState.ts#L56-L68, which drops any dynamic-screen param not declared inDYNAMIC_ROUTES[...].queryParamsunless the underlying screen happens to carry it.SETTINGS_SPLIT_NAVIGATORis already active (linkTo/index.ts#L145-L158) or while any RHP is already open (linkTo/index.ts#L261),linkTodoes not placeSettings_Security?forceSetup=trueunderneath. Step 1 → Step 2 rebuilds its URL frombackPathwithoutforceSetup, andDynamicSuccessPage.tsx#L46-L49also gatesisForcedSetupFlowandshouldReturnToOnboardingAfter2FA(#L68) onisSecuritySettingsFlow.Settings_Securitydoes receiveparams: {forceSetup: 'true'},GetStateForActionHandlers.ts#L366-L373preserves non-target tab state on Home reveal, leaving?forceSetup=trueonSettings_Securityso a later voluntary setup fromSecuritySettingsPage.tsx#L114(getTwoFactorAuthRoute()resolvinggetActiveRoute()atcreateDynamicRoute.ts#L83) inheritsforceSetup=true.What changes do you think we should make in order to solve the problem?
Move
forceSetupownership ontoDYNAMIC_ROUTES.TWO_FACTOR_AUTH_*(src/ROUTES.ts,src/hooks/useTwoFactorAuthRoute.ts,src/libs/Navigation/types.ts,RequireTwoFactorAuthenticationOverlay.tsx, and the 2FA dynamic step pages):getRouteandqueryParams: ['forceSetup']on the fourTWO_FACTOR_AUTH_*entries insrc/ROUTES.ts(matchingVERIFY_ACCOUNT/ADD_BANK_ACCOUNT_VERIFY_ACCOUNT), sogetPathFromStatepreservesforceSetup=trueon the active 2FA route whilegetPathWithoutDynamicSuffixautomatically stripsforceSetupfrombackPath:useTwoFactorAuthRoute.ts, build the suffix withDYNAMIC_ROUTES.TWO_FACTOR_AUTH_VERIFY_ACCOUNT.getRoute(options)andDYNAMIC_ROUTES.TWO_FACTOR_AUTH_ROOT.getRoute(options), and inRequireTwoFactorAuthenticationOverlay.tsx#L118pass cleanROUTES.SETTINGS_SECURITY.getRoute()with{forceSetup: true}(removing theforceSetupparam fromROUTES.SETTINGS_SECURITY.getRoutesoSettings_Securityis never polluted).{forceSetup?: string}onDYNAMIC_ROOT,DYNAMIC_VERIFY_ACCOUNT, andDYNAMIC_VERIFYinTwoFactorAuthNavigatorParamList, and forward{forceSetup: route.params?.forceSetup === 'true'}in the intra-flowDYNAMIC_ROUTES.TWO_FACTOR_AUTH_*.getRoute(...)transitions inDynamicTwoFactorAuthVerifyAccountPage.tsx,DynamicTwoFactorAuthPage.tsx, andDynamicVerifyPage.tsx.Add a single-turn synchronous modal-dismiss-to-route helper for removal events (
Navigation.ts,createRootStackNavigator/types.ts,addRootHistoryRouterExtension.ts):shouldFreezeHistory?: boolean(defaulttrue) toREPLACE_FULLSCREEN_UNDER_RHPsoaddRootHistoryRouterExtension.ts#L77skipsgetFrozenHistoryStateForReplaceFullscreenUnderRHPwhenaction.payload.shouldFreezeHistory === false.Navigation.dismissModalToRoute(route, {afterTransition})insrc/libs/Navigation/Navigation.ts, which synchronously dispatchesREPLACE_FULLSCREEN_UNDER_RHP(shouldFreezeHistory: false) followed immediately bydismissModal({afterTransition})in the same turn:Because both dispatches commit synchronously inside
beforeRemove, root state becomes[Tab(Home)](history.length = 1) in the same turn:useLinkingseesafterState !== beforeState(norollbackHistory()), single browser back (pendingPopStateDelta = -1) computeshistoryDelta = 1 - 2 - (-1) = 0andhistory.replaces/settings/securityin place with/home, backdrop/Escape (pendingPopStateDelta = null) pops the modal entry and replaces/settings/securitywith/home,RESETcannot overwriteHome, andDISMISS_MODALcloses the entireRightModalNavigatoreven if another RHP was open underneath.Decouple forced flags from
isSecuritySettingsFlowand intercept non-button removals inDynamicSuccessPage.tsx:const isForcedSetupFlow = route.params?.forceSetup === 'true';andconst shouldReturnToOnboardingAfter2FA = (isSecuritySettingsFlow || isForcedSetupFlow) && isForcedOnboardingHandoff;.isExitingForcedSetupRefanduseBeforeRemove(src/hooks/useBeforeRemove.tsx):Set
isExitingForcedSetupRef.current = trueat the start ofcompleteForcedOnboarding2FAHandoffandsendForcedSetupUserHomeso Got it and the header back arrow keep their existing two-framerevealRouteBeforeDismissingModaltransition unimpeded, while voluntary Settings, USD bank account, and Xero 2FA flows remain untouched.What alternative solutions did you explore? (Optional)
Settings_Security?forceSetup=truefromRequireTwoFactorAuthenticationOverlaywhen on the Settings tab: Still fails when an RHP is already open (linkToskips fullscreen matching wheneverRIGHT_MODAL_NAVIGATORis on top) and leavesforceSetup: 'true'persisted onSettings_SecurityinSETTINGS_SPLIT_NAVIGATORfor subsequent voluntary setups in the same session.REPLACE_FULLSCREEN_UNDER_RHPonDynamicSuccessPagemount (preInsertFullscreenUnderRHP) or insidebeforeRemovewithoute.preventDefault(): Mount-time pre-insertion freezes history viapendingRevealand disables RHP slide animations; skippinge.preventDefault()breaks onCommonActions.reset(rapid browser back), leakspendingReveal, and only pops one inner screen when another RHP was stacked belowTwoFactorAuth.neerajbachani commentedon Nov 12, 2026
@laveshfonix Thanks for running it.
The steps in the issue start from login. On staging, Got it on that success screen already goes Home. Back is what still lands on Account > Security, and that is what the selected proposal fixes.
Your video starts with the Settings tab already open, so the setup opens over that Account page and forceSetup never reaches the success screen. That is why Got it stays on the Enabled page and back stays on Security or Profile. I can cover that start in the PR if we want it in this issue. Thanks!!
@MariaHCD Waiting for the assignment here, thanks!!
melvin-bot commentedon Nov 12, 2026
📣 @neerajbachani You have been assigned to this job!
Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑💻
Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs!
Keep in mind: Code of Conduct | Contributing 📖
expensify-chore-bot commentedon Nov 17, 2026
@neerajbachani Huh... This is 4 days overdue. Who can take care of this?
daledah commentedon Nov 18, 2026
friendly bump here @neerajbachani