[$250] Travel card -"Let's make sure it's you" page is displayed after tapping back arrow
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: v9.5.37-1 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://github.com/Expensify/App/pull/106553 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 (hyperlinked to channel name):
Action Performed:
Preconditions: The account has the Travel and Consolidated Travel Billing features enabled with a bank account set up.
- Open the Expensify app
- Go to Account > Wallet
- Tap on Travel CVV
- Tap the back arrow button in the app
Expected Result:
The CVV card page is displayed after tapping the back arrow button once.
Actual Result:
The "Let's make sure it's you" page is displayed again after tapping the back arrow button once.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome / Safari
Screenshots/Videos
https://github.com/user-attachments/assets/0aae8fe0-8309-40b0-aa55-175fb0a5b9b5
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022121005826537852944
- Upwork Job ID: 2121005826537852944
- Last Price Increase: 2026-12-01
Issue Owner
Current Issue Owner: @QichenZhu
Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan (External)
Job added to Upwork: https://www.upwork.com/jobs/~022121005826537852944
🤖 Web test steps verification results: ⚠️ partial
The app and Wallet were reached on dev NewDot web. Missing prerequisites blocked Travel CVV testing; the reported bug was not reproduced or verified.
| Step | Status |
|---|---|
Open ExpensifyThe authenticated app opened. |
✅ |
Go to Account > WalletWallet was reached successfully. |
✅ |
Tap Travel CVVBlocked: no Travel CVV entry appeared. Wallet showed “Add a bank account to make or receive payments.”![]() |
⚠️ |
Tap the in-app back arrow onceUnverified because Travel CVV could not be opened. |
⚠️ |
⚠️ Preliminary analysis — low confidence in the root cause
Findings: The reported release already contains protections that should prevent this behavior:
- Verification’s back action explicitly targets the CVV page: TravelCVVVerifyAccountPage.tsx:36–38.
- The CVV page records that it automatically opened verification before navigating, preventing another automatic opening when returning to the same component: TravelCVVPage.tsx:65–105.
Remaining hypothesis: If Back recreates the CVV page instead of returning to the existing instance, its navigation guard resets and verification could immediately reopen. Navigation has a replacement fallback when it cannot return to the target route: Navigation.ts:614–637. That prerequisite has not been demonstrated. Alternatively, Back might leave the original verification screen unchanged.
Next diagnostic step: On an eligible account, capture route names/keys and CVV mount/unmount events immediately before and after one in-app Back press. This distinguishes a replacement/reopen from an ineffective Back action. Do not capture CVV values or verification codes.
No code fix or offending PR is established by the available evidence; changing the back destination would not address a demonstrated defect.
Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On the Travel CVV page, the app automatically opens the "Let's make sure it's you" (validate code) page. When the user taps the back arrow on that page, they should land on the Travel CVV page, but the validate code page opens again.
What is the root cause of that problem?
The guard that stops TravelCVVPage from auto-opening the verify page again is local to the component instance:
hasAutoNavigatedRefis auseRefinsrc/pages/settings/Wallet/TravelCVVPage/TravelCVVPage.tsx(around lines 65–105).- The second guard,
isVerifyAccountInStack, is onlytruewhileTRAVEL_CVV_VERIFY_ACCOUNTis still in the navigation state.
When the user presses back on the verify page, TravelCVVVerifyAccountPage calls Navigation.goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV). That pops the verify route, so isVerifyAccountInStack becomes false. If TravelCVVPage is re-mounted at that point, which can happen when goBack(route) resolves to the fallback route instead of simply popping, hasAutoNavigatedRef is reset to false. The effect then passes every check (not loading, no CVV, not a delegate, online, not locked) and calls Navigation.navigate(ROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT) again.
So "already auto-opened verification for this flow" is stored somewhere that doesn't survive the trip back from the verify page.
What changes do you think we should make in order to solve the problem?
Store the "auto-opened once" flag in TravelCVVContextProvider, which already wraps both Travel CVV screens and lives for the whole flow, instead of in a component useRef.
-
TravelCVVPage/types.tsanddefault.ts: addhasAutoOpenedVerifyAccount: booleanto the state type, andsetHasAutoOpenedVerifyAccountto the actions type (defaultfalse/ noop). -
TravelCVVContextProvider.tsx:
const [hasAutoOpenedVerifyAccount, setHasAutoOpenedVerifyAccount] = useState(false);
// add both to stateValue / actionsValue
TravelCVVPage.tsx: read the flag from context and use it in place of the ref.
const {cvv, hasAutoOpenedVerifyAccount} = useTravelCVVState();
const {setCvv, setHasAutoOpenedVerifyAccount} = useTravelCVVActions();
useEffect(() => {
if (hasAutoOpenedVerifyAccount || isVerifyAccountInStack) {
setHasAutoOpenedVerifyAccount(true);
return;
}
if (isLoadingAccount || isLoadingLockAccountDetails) {
return;
}
if (cvv || isSignedInAsDelegate) {
setHasAutoOpenedVerifyAccount(true);
return;
}
if (isOffline || isAccountLocked) {
return;
}
setHasAutoOpenedVerifyAccount(true);
Navigation.navigate(ROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT);
}, [hasAutoOpenedVerifyAccount, isLoadingAccount, isLoadingLockAccountDetails, cvv, isSignedInAsDelegate, isOffline, isAccountLocked, isVerifyAccountInStack]);
Because the provider unmounts when the user leaves the Travel CVV flow, re-opening Travel CVV from Wallet still auto-opens verification once, as intended. Coming back from the verify page, by back arrow or by successful verification, no longer opens it a second time. The user stays on the Travel CVV page and can still tap "Reveal details" manually.
- (Optional hardening) In
TravelCVVVerifyAccountPage.tsx, useNavigation.goBack()when the CVV route is the previous route, and only fall back toROUTES.SETTINGS_WALLET_TRAVEL_CVVwhen the page was opened directly (deep link). This avoids re-creating the CVV screen on back.
I'll add a unit test that renders the flow, simulates back from the verify page, and asserts Navigation.navigate is called only once with SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT.
What alternative solutions did you explore? (Optional)
- Using a module-level variable instead of context. This was rejected because it would survive leaving the flow and stop the intended auto-open on the next visit.
- Removing auto-navigation entirely. That works, but it changes the intended UX of opening verification automatically.
📣 @Hassank007! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Proposal
What is the root cause of that problem?
-
In
src/pages/settings/Wallet/TravelCVVPage/TravelCVVPage.tsx, the auto-navigation mechanism uses two guards:hasAutoNavigatedRef: a component-leveluseRef(false)which is reset wheneverTravelCVVPageis remounted during stack transitions.isVerifyAccountInStack: checks whetherSCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNTexists instate.routes. When the user taps the back arrow onTravelCVVVerifyAccountPage, the verify route is popped from the navigation stack. Consequently,isVerifyAccountInStackisfalse. WhenTravelCVVPagere-renders upon returning,hasAutoNavigatedRefisfalse(or reset), andisVerifyAccountInStackisfalse, causing theuseEffectto pass all checks and auto-navigate immediately back toROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT.
-
Additionally, in
TravelCVVVerifyAccountPage.tsx,navigateBackcallsNavigation.goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV)with a route argument, which routes throughgoUp()and dispatches aNAVIGATEaction back toSETTINGS_WALLET_TRAVEL_CVVinstead of cleanly popping the active verify screen withNavigation.goBack().
What changes do you think we should make in order to solve the problem?
-
Persist the auto-navigation flag across the Travel CVV flow via context:
- In
TravelCVVContextProvider, addhasAutoNavigated: boolean(defaulting tofalse) and a corresponding settersetHasAutoNavigated. - In
TravelCVVPage.tsx, consumehasAutoNavigatedandsetHasAutoNavigatedfrom the context actions/state instead of using the localuseRef. - In
TravelCVVPage.tsx's unmount effect (useEffect(() => () => ...)), resetsetHasAutoNavigated(false)alongsidesetCvv(null). BecauseTravelCVVContextProvideris composed at theAuthScreenslevel and remains mounted while the user is logged in, resettinghasAutoNavigatedwhenTravelCVVPageunmounts ensures that subsequent independent visits to Travel CVV from the Wallet page will still auto-open the verification screen as intended.
- In
-
Clean stack pop on cancel:
- In
TravelCVVVerifyAccountPage.tsx, updatenavigateBackto callNavigation.goBack()without arguments when popping back toTravelCVVPage, reservingROUTES.SETTINGS_WALLET_TRAVEL_CVVstrictly as a fallback if the navigator cannot go back.
- In
What alternative solutions did you explore? (Optional)
Using route params on ROUTES.SETTINGS_WALLET_TRAVEL_CVV (e.g. ?cancelled=true), but utilizing the existing dedicated TravelCVVContextProvider with proper unmount cleanup keeps navigation clean and keeps state encapsulated within the Travel CVV feature.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013a67ef94568f56ff
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal (updated)
What is the root cause of that problem?
Two corrections and an addition to my proposal above, after re-checking main:
TravelCVVContextProvideris mounted once inAuthScreens.tsx(~L195), so it lives for the whole signed-in session, not only the Travel CVV flow.- Both screens are in the same RHP stack. On a clean stack,
goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV)ends inpop(1), so the CVV page is not remounted. The bug therefore needs one of two stack states, and both end with the verify page showing again after one back press:- A. CVV page remounted: if
canPopToRoutefails,goUp()dispatchesREPLACE(Navigation.ts~L614-620). A newTravelCVVPagemounts withhasAutoNavigatedRef = falsewhileisVerifyAccountInStackisfalse, so it auto-opens verification again. The unmount cleanupsetCvv(null)also wipes any revealed CVV. - B. Verify page pushed twice: the guard is per instance (
useRef). If the auto-open runs from more than oneTravelCVVPageinstance, or again before the stack update lands,[CVV, VERIFY, VERIFY]is created. One back press then reveals the second verify page.
- A. CVV page remounted: if
Both come from the same weakness: "auto-opened already" is tracked per component instance instead of once per visit.
What changes do you think we should make in order to solve the problem?
This covers both A and B:
- Track the auto-open once per visit, synchronously, in the provider. In
TravelCVVContextProvider, addconst hasAutoOpenedVerifyAccountRef = useRef(false);and expose it through the actions context. It's a ref, not state, so it is stable and updates synchronously, and two instances or two quick effect runs can't both pass the check. Add it totypes.ts/default.ts. TravelCVVPage.tsx: replace the localhasAutoNavigatedRefwith the shared ref (same effect logic; set.current = truebeforeNavigation.navigate).- Reset it only at the entry point. In
PaymentMethodList.tsx(Travel CVV row, ~L586):hasAutoOpenedVerifyAccountRef.current = false;beforeNavigation.navigate(ROUTES.SETTINGS_WALLET_TRAVEL_CVV). Each new visit from Wallet still auto-opens once. Remounts inside the flow don't reset it, so the reset is deliberately not in the unmount cleanup. - Avoid the remount on back. In
TravelCVVVerifyAccountPage.tsx, when the previous route isTRAVEL_CVV, callNavigation.goBack(). KeepROUTES.SETTINGS_WALLET_TRAVEL_CVVas the fallback for deep links.
Tests: (a) back from verify → navigate(SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT) was called once; (b) remount TravelCVVPage inside the flow → no second auto-open; (c) leave and re-enter from Wallet → auto-opens again.
Note: I couldn't reproduce this myself, because it needs a Travel + Consolidated Travel Billing account. The changes are written to work whichever of A or B happens on the tester's device.
What alternative solutions did you explore? (Optional)
- Reset the flag in the
TravelCVVPageunmount cleanup. Rejected: the remount in A runs that cleanup, so the bug comes back. - Store the flag as React state in the provider. Rejected: state updates are async, so it doesn't close case B.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When the user taps Travel CVV under Account > Wallet, the app opens TravelCVVPage and automatically navigates to TravelCVVVerifyAccountPage ("Let's make sure it's you"). When the user taps the back arrow button once on TravelCVVVerifyAccountPage, instead of returning to and staying on TravelCVVPage, the "Let's make sure it's you" screen is displayed again.
What is the root cause of that problem?
The root cause is in src/pages/settings/Wallet/TravelCVVPage/TravelCVVPage.tsx (lines 65–105) combined with how Navigation.goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV) in src/pages/settings/Wallet/TravelCVVPage/TravelCVVVerifyAccountPage.tsx (lines 36–38) resolves back navigation:
-
Why a single back press re-triggers auto-navigation when
TravelCVVPageis remounted (goUpfallback /REPLACE) or when two auto-navigations race:- In
TravelCVVPage.tsx,hasAutoNavigatedRef = useRef(false)is stored on the component instance rather than across the active Travel CVV session inTravelCVVContextProvider. - Meanwhile, the secondary guard
isVerifyAccountInStack(state.routes.some((route) => route.name === SCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNT)) is onlytruewhileTRAVEL_CVV_VERIFY_ACCOUNTis still present instate.routes. - When the user presses the back arrow on
TravelCVVVerifyAccountPage,navigateBack()callsNavigation.goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV). OnceTRAVEL_CVV_VERIFY_ACCOUNTis popped or replaced:isVerifyAccountInStackimmediately becomesfalse.- If
TravelCVVPageis remounted during the back transition (for example whengoUpfalls back toREPLACEinsrc/libs/Navigation/Navigation.ts:617-620, or after a deep link / reload on/settings/wallet/travel-cvv/verify-account), the newTravelCVVPageinstance starts withhasAutoNavigatedRef.current === falseandisVerifyAccountInStack === false. ItsuseEffectimmediately passes every guard and callsNavigation.navigate(ROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT)again. - Worse, if the user just completed verification (
setCvv(cardDetails.cvv ?? null)followed bynavigateBack()inTravelCVVVerifyAccountPage.tsx:49-50), any unmount/remount ofTravelCVVPagerunsuseEffect(() => () => setCvv(null), [setCvv])(TravelCVVPage.tsx:60), wiping the newly revealed CVV and immediately re-openingTravelCVVVerifyAccountPage! - Furthermore, because
Navigation.navigate(ROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT)schedules navigation viaNavigation.isNavigationReady().then(...),isVerifyAccountInStackdoes not flip totruesynchronously. IfTravelCVVPageremounts or a second instance renders before the navigation state commits, twoTRAVEL_CVV_VERIFY_ACCOUNTroutes are pushed ([TRAVEL_CVV, TRAVEL_CVV_VERIFY_ACCOUNT, TRAVEL_CVV_VERIFY_ACCOUNT]), so tapping the back arrow once pops only the top screen and leaves the duplicate verify screen visible.
- In
-
Why
TravelCVVContextProviderlifecycle must be respected cleanly (without coupling unrelated callers likePaymentMethodList):TravelCVVContextProvideris mounted at theAuthScreenslevel (src/libs/Navigation/AppNavigator/AuthScreens.tsx:195), so it stays mounted for the entire authenticated session.- However, resetting the auto-navigation flag inside
PaymentMethodList.tsx(at the Wallet rowonPress) is brittle becauseROUTES.SETTINGS_WALLET_TRAVEL_CVVcan also be reached via deep link, browser history, orgoBackfallback—and resetting it unconditionally inTravelCVVPage'suseEffect(() => () => ...)unmount cleanup breaks wheneverTravelCVVPageremounts whileTRAVEL_CVVorTRAVEL_CVV_VERIFY_ACCOUNTis still active in the navigation state. - Instead, cleanup should only reset
cvvand the auto-navigation guard when the user has actually exited the Travel CVV flow (i.e. neitherSCREENS.SETTINGS.WALLET.TRAVEL_CVVnorSCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNTremains in the navigation state).
What changes do you think we should make in order to solve the problem?
- Track
hasAutoNavigatedRefinTravelCVVContextProvider(src/pages/settings/Wallet/TravelCVVPage/types.ts,default.ts, andTravelCVVContextProvider.tsx):- Add
hasAutoNavigatedRef: React.MutableRefObject<boolean>(orhasAutoNavigatedgetter/setter backed by a synchronous ref inTravelCVVContextProvider) so that marking auto-navigation as completed is synchronous and survives any remount ofTravelCVVPagewithin the same Travel CVV flow.
- Add
// src/pages/settings/Wallet/TravelCVVPage/TravelCVVContextProvider.tsx
const [cvv, setCvv] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(false);
const [validateError, setValidateError] = useState<Errors>({});
const hasAutoNavigatedRef = useRef(false);
- Update
src/pages/settings/Wallet/TravelCVVPage/TravelCVVPage.tsxto use the context ref and only clear state when leaving the Travel CVV flow:- Replace the local
hasAutoNavigatedRefwith the sharedhasAutoNavigatedReffromTravelCVVContextProvider. - When
TravelCVVPageunmounts, checkNavigation.isTopmostRouteModalScreen()/ current root navigation state: only resetsetCvv(null)andhasAutoNavigatedRef.current = falsewhen neitherSCREENS.SETTINGS.WALLET.TRAVEL_CVVnorSCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNTis in the active stack. That way:- Returning from
TravelCVVVerifyAccountPage(even ifTravelCVVPageremounts or if the user deep-linked directly toTRAVEL_CVV_VERIFY_ACCOUNTand pressed Back) never re-opensTravelCVVVerifyAccountPageand never wipes a just-revealedcvv. - Closing the Travel CVV flow back to Wallet (or dismissing the RHP modal) cleanly resets both
cvvandhasAutoNavigatedRef.current = false, so the next time the user taps Travel CVV from Wallet, it auto-opens verification once as intended.
- Returning from
- Replace the local
// src/pages/settings/Wallet/TravelCVVPage/TravelCVVPage.tsx
const {cvv} = useTravelCVVState();
const {setCvv, hasAutoNavigatedRef} = useTravelCVVActions();
useEffect(
() => () => {
if (
Navigation.isRouteInRootState(SCREENS.SETTINGS.WALLET.TRAVEL_CVV) ||
Navigation.isRouteInRootState(SCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNT)
) {
return;
}
setCvv(null);
hasAutoNavigatedRef.current = false;
},
[setCvv, hasAutoNavigatedRef],
);
(Or inline helper checking navigationRef.current?.getRootState() for SCREENS.SETTINGS.WALLET.TRAVEL_CVV / TRAVEL_CVV_VERIFY_ACCOUNT.)
-
Mark
hasAutoNavigatedRef.current = trueinsideTravelCVVVerifyAccountPage.tsxon mount as well:- In
src/pages/settings/Wallet/TravelCVVPage/TravelCVVVerifyAccountPage.tsx, sethasAutoNavigatedRef.current = truewhenTravelCVVVerifyAccountPagemounts. This guarantees that even if the user opened/settings/wallet/travel-cvv/verify-accountdirectly via deep link/reload and then tapped the back arrow (which mountsTravelCVVPagefor the first time viaNavigation.goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV)),TravelCVVPageknows the user just came back fromTravelCVVVerifyAccountPageand will not bounce them back to the verify page.
- In
-
Add UI regression tests (
tests/ui/TravelCVVPageTest.tsx):- Verify that mounting
TravelCVVPageauto-navigates toROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNTonce. - Verify that pressing the back arrow from
TravelCVVVerifyAccountPage(including whenTravelCVVPagemounts/remounts on back) keeps the user onTravelCVVPagewithout callingNavigation.navigate(ROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT)a second time. - Verify that leaving the Travel CVV flow and re-entering from Wallet resets the guard and auto-navigates once again.
- Verify that mounting
What alternative solutions did you explore? (Optional)
- Resetting the ref inside
PaymentMethodList.tsx'sonPresshandler: rejected because it couplesPaymentMethodListtoTravelCVVContextProviderinternals and fails when entering Travel CVV via deep link or whenTravelCVVPageis first mounted ongoBackfrom a deep-linkedTravelCVVVerifyAccountPage. - Resetting the flag unconditionally in
TravelCVVPage's unmount cleanup: rejected because ifTravelCVVPageunmounts/remounts during stack replacement, the cleanup resets the flag (and clearscvv), reproducing the exact bug.
Proposal
What is the root cause of that problem?
- Component-local auto-navigation tracking in
TravelCVVPage.tsx: Insrc/pages/settings/Wallet/TravelCVVPage/TravelCVVPage.tsx(lines 69–105), the guardhasAutoNavigatedRef = useRef(false)is stored locally within theTravelCVVPagecomponent instance rather than in the shared session context (TravelCVVContextProvider). - Navigation stack popping vs replacement in
TravelCVVVerifyAccountPage.tsx: Insrc/pages/settings/Wallet/TravelCVVPage/TravelCVVVerifyAccountPage.tsx(lines 36–38),navigateBackcalls:
Passing an explicitNavigation.goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV);backToRoutecausesNavigation.goBackto invokegoUp(ROUTES.SETTINGS_WALLET_TRAVEL_CVV). WhencanPopToRouteevaluates to false (e.g. during nested stack transitions or deep-link navigation states),goUpfalls back to dispatchingREPLACE(src/libs/Navigation/Navigation.ts:617-620), replacing the verification route with a brand-newTravelCVVPageinstance. - Re-triggering the auto-navigation effect:
When
TravelCVVPagemounts afresh:hasAutoNavigatedRef.currentinitializes tofalse.isVerifyAccountInStack(state.routes.some((route) => route.name === SCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNT)) evaluates tofalsebecauseTRAVEL_CVV_VERIFY_ACCOUNTwas just replaced in the stack.- The unmount cleanup of the previous instance ran
setCvv(null)(line 60), leavingcvvasnull. - Consequently, all guards in
useEffectpass, andNavigation.navigate(ROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT)is called again, bouncing the user right back into the verification screen.
What changes do you think we should make in order to solve the problem?
-
Move Auto-Navigation Guard to
TravelCVVContextProvider:- In
src/pages/settings/Wallet/TravelCVVPage/TravelCVVContextProvider.tsx, add a synchronous refhasAutoNavigatedRef = useRef(false)to state/actions context:const hasAutoNavigatedRef = useRef(false); - Expose
hasAutoNavigatedRefinTravelCVVActionsContextType(src/pages/settings/Wallet/TravelCVVPage/types.tsanddefault.ts). - Because
hasAutoNavigatedRefis stored in the context provider, it survives any remount or replacement ofTravelCVVPagewithin the active Travel CVV flow.
- In
-
Consume Shared Guard in
src/pages/settings/Wallet/TravelCVVPage/TravelCVVPage.tsx:- Replace the local
hasAutoNavigatedRef = useRef(false)with thehasAutoNavigatedRefprovided byuseTravelCVVActions(). - In
TravelCVVPage.tsxunmount cleanup, only resetcvvandhasAutoNavigatedRef.current = falsewhen actually navigating away from the Travel CVV flow (i.e. neitherSCREENS.SETTINGS.WALLET.TRAVEL_CVVnorSCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNTis present in the navigation state).
- Replace the local
-
Standardize Back Navigation in
src/pages/settings/Wallet/TravelCVVPage/TravelCVVVerifyAccountPage.tsx:- In
navigateBack, callNavigation.goBack()directly if the previous screen in the stack isTRAVEL_CVV, avoiding thegoUpfallback toREPLACE:const navigateBack = () => { Navigation.goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV); }; - Additionally, in
TravelCVVVerifyAccountPage.tsx, ensurehasAutoNavigatedRef.current = trueis set on mount so that even if the user lands directly on the verification screen via a deep link or page reload and taps Back,TravelCVVPageknows verification was already presented and will not trigger a duplicate auto-navigation.
- In
-
Automated Regression Tests (
tests/ui/TravelCVVPageTest.tsx):- Test 1: On initial mount from Wallet,
TravelCVVPageauto-navigates toROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNTexactly once. - Test 2: Tapping the back button on
TravelCVVVerifyAccountPagereturns toTravelCVVPagewithout triggering a second auto-navigation toTRAVEL_CVV_VERIFY_ACCOUNT. - Test 3: Dismissing the Travel CVV modal and re-entering from Wallet resets the guard and auto-navigates once again.
- Test 1: On initial mount from Wallet,
What alternative solutions did you explore? (Optional)
- Resetting the flag inside
PaymentMethodList.tsx'sonPress: Rejected because it creates an unnecessary coupling betweenPaymentMethodListandTravelCVVContextProviderinternals, and does not handle deep linking or page refresh flows. - Removing auto-navigation entirely: Rejected because auto-opening verification is the intended UX designed so that users do not need to manually click "Reveal Details" upon initial visit. Keeping the auto-open behavior while storing the guard in the flow provider achieves the intended UX with zero re-navigation loops.
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
@MelvinBot post official proposal
🤖 Web test steps verification results: ⚠️ partial
The app and Wallet opened, but missing Travel CVV prerequisites blocked reproduction. Independently of existing proposals, I could not establish the root cause, so an official fix proposal would be speculative.
| Step | Status |
|---|---|
Open ExpensifyThe signed-in app opened successfully. |
✅ |
Go to Account > WalletWallet opened successfully. |
✅ |
Open Travel CVVBlocked: no Travel CVV entry appeared, and Wallet requested a bank account.![]() |
⚠️ |
Press the in-app back arrow onceUnverified because verification was unreachable.Independent investigation confirmed that the reported release already sets its one-time guard before opening verification: TravelCVVPage.tsx:65–105. Normal back navigation should preserve that instance; a remount has not been demonstrated. To establish the fix, capture navigation actions, route keys, and CVV mount/unmount events on an eligible account around one Back press. This will distinguish replacement/reopening from an ineffective Back action. Do not capture CVV values or verification codes. |
⚠️ |
@situchan Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@situchan Huh... This is 4 days overdue. Who can take care of this?
Hi @situchan 👋 — happy to take this one forward whenever you've had a chance to review.
Quick recap of my proposal (and the update) in case it helps unblock the pick: it's built to fix the bug whichever stack state actually occurs on the tester's device, since the repro needs a Travel + Consolidated Billing account:
- Case A —
TravelCVVPageremounts (whengoUp()falls back toREPLACE): the localuseRefguard resets and auto-opens verification again. - Case B — verify page pushed twice (per-instance guard + async stack update race): one back press reveals the duplicate.
Both come from the same root cause — "already auto-opened" is tracked per component instance. My fix moves that flag into TravelCVVContextProvider as a ref (synchronous, so it closes the Case B race, which React state wouldn't) and resets it only at the Wallet entry point, so re-entry still auto-opens once as intended.
Happy to raise the PR as soon as it's assigned, and glad to help with repro steps if that's the blocker. Thanks!
@situchan Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!
Claude posting on behalf of Matt:
@QichenZhu you're now the C+ on this issue. The previous C+ is no longer in the Contributor program. Next step: review the proposals.
Since MelvinBot didn't post a proposal, I'm adding the Help Wanted label. Only proposals posted after the label will be reviewed. If the authors of the proposals above are still interested in this issue, please delete/hide your original proposal and post a new one below.
:sos: C+ Help Wanted
Proposal
What is the root cause of that problem?
The Travel CVV page is never under the verify page in the first place, so Back has nothing to return to. I reproduced this in a Jest test that uses our real RootStackRouter, createRightModalNavigator and linkTo, so it doesn't need a Travel account. Here's the chain:
TravelCVVPageopens the verify page from a mount effect (TravelCVVPage.tsx#L69-L105).- On the first open, that effect runs in the same commit where the RHP and its Settings stack mount. React runs child effects before parent effects, and React Navigation adds a newly mounted navigator's state to its parent in that navigator's own
useEffect. So whenNavigation.navigateruns, the RHP route in the root state has nostateyet. - Because of that,
getMinimalActionstops at the root (getMinimalAction.ts#L65-L67), and the action becomes a PUSH of a newRightModalNavigatoron the root stack. RootStackRouterhandles that as "opening a modal from a modal" and first removes the RHP on top (RootStackRouter.ts#L177-L187, GetStateForActionHandlers.ts#L816-L823). The RHP that held Travel CVV is thrown away and the new one contains only[VerifyAccount]. Travel CVV unmounts, and itshasAutoNavigatedRefis gone with it.- Back calls
Navigation.goBack(ROUTES.SETTINGS_WALLET_TRAVEL_CVV)(TravelCVVVerifyAccountPage.tsx#L36-L38). The CVV route isn't in the stack, sogoUpreplaces verify with a new Travel CVV (Navigation.ts#L617-L620). That new instance starts with a fresh ref, so it opens verify again:[TravelCVV, VerifyAccount]. - Modal stacks animate a replace as a pop (useModalStackScreenOptions.ts#L81), so on screen it looks like Back revealed a second verify page. That's exactly what the video shows at ~0:07: verify slides out, another verify is underneath, and Travel CVV never appears. The second Back works because the new instance has already set its ref.
The same cause also makes Android back or iOS swipe on that first verify page close the whole RHP back to Wallet, because there's nothing under verify.
What changes do you think we should make in order to solve the problem?
I'd fix it where the auto-navigation happens: in TravelCVVPage, let the navigators register before we push verify. We already have a helper for this, deferNavigate (@libs/Navigation/deferNavigate):
hasAutoNavigatedRef.current = true;
deferNavigate(() => Navigation.navigate(ROUTES.SETTINGS_WALLET_TRAVEL_CVV_VERIFY_ACCOUNT));
This doesn't depend on timing luck. React runs all passive effects of a commit in one synchronous pass, so the microtask always runs after the RHP and Settings stack have added their state. linkTo then pushes verify inside the existing Settings stack: [TravelCVV, VerifyAccount]. Back pops to the same Travel CVV instance, its ref is still true, and verify doesn't open again. The existing guards (offline, locked, delegate, CVV already revealed, isVerifyAccountInStack) stay the same, and TravelCVVVerifyAccountPage doesn't change.
I'll add tests/ui/TravelCVVPageTest.tsx. It renders the real TravelCVVPage inside the real root, RHP and Settings stack navigators and checks:
- Opening from Wallet gives
[TravelCVV, VerifyAccount]. - One press of the back arrow lands on Travel CVV.
- Hardware or swipe back lands on Travel CVV.
On main, 0/3 pass: the stack is [VerifyAccount], then [TravelCVV, VerifyAccount] after Back, and hardware back closes the RHP. With the change, 3/3 pass. No existing test covers TravelCVVPage, and the change doesn't touch shared navigation code. I don't have a Travel-enabled account, so I haven't checked this on a device. The repro is the test above.
What alternative solutions did you explore? (Optional)
- Push with the screen's own
navigation.navigate(SCREENS.SETTINGS.WALLET.TRAVEL_CVV_VERIFY_ACCOUNT). It also gives[TravelCVV, VerifyAccount]in my test. I didn't pick it because it bypassesNavigation.navigate, which NAVIGATION.md asks us to use. - Make
getMinimalActiondescend intoparams.screenwhen a route has nostateyet. That would fix any page that navigates from a mount effect inside a freshly opened RHP, but it changes routing for the whole app, which is too wide for this bug. - Keep the "already opened" flag outside the page. That only hides the second auto-open. The RHP is still replaced on open, so hardware or swipe back still exits to Wallet. I checked this in the same test setup.