App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-12-08] [$175] Bank Account - User does not land back on the country selector after closing the Plaid UI

Open applause-bot[bot] opened this issue 2 weeks ago • 23 comments

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


Version Number: 9.5.39-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/83545950/folder/57527124/41236749/1969266086 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Android 16 / Samsung A34 App Component: Other

Action Performed:

Precondition: Logged into Expensify App with a new Expensifail account and reset the App's Cache.

  1. Open the Expensify App.
  2. Tap the "Account" icon.
  3. Tap "Wallet".
  4. Tap "Add bank account".
  5. Tap "Get reimbursed".
  6. Select "United States" from the "Where's your bank account located?" list. Go to Settings > Wallet > Add bank account.
  7. Tap "Next".
  8. Tap "Log into your bank".
  9. Tap the "X" icon on the "Plaid" card.
  10. Tap "Yes, exit" on the "Are you sure?"

Expected Result:

The user should land back on the country selector after closing the Plaid UI.

Actual Result:

The User does not land back on the country selector after closing the Plaid UI.

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/9997f967-c185-4c3c-b775-9d517ce4d508

View all open jobs on GitHub

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

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

applause-bot[bot] avatar Nov 13 '26 14:11 applause-bot[bot]

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

https://platform.applause.com/services/links/v1/external/60344ae158ded82f1d482c841dbbf58157636d1de9e626922ec8d1221c0a3bb7

applause-bot[bot] avatar Nov 13 '26 14:11 applause-bot[bot]

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

melvin-bot[bot] avatar Nov 13 '26 14:11 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022121252902567865588

melvin-bot[bot] avatar Nov 13 '26 14:11 melvin-bot[bot]

🤖 Web test steps verification results: ⚠️ partial

Reached Add bank account on dev NewDot web, then encountered emailed-code account validation. Plaid cancellation remains untested; code evidence supports the navigation explanation below with medium confidence.

Step Status
Open Expensify with a fresh accountFresh-account session was signed in with onboarding complete.
✅
Open AccountAccount opened.
✅
Open WalletWallet displayed Bank accounts and Add bank account.
✅
Choose Add bank accountAccount validation requested an emailed six-digit security code.
✅
Choose Get reimbursedBlocked by account validation.
⚠️
Select United StatesNot reached.
⚠️
Click NextNot reached.
⚠️
Click Log into your bankNot reached.
⚠️
Click X in PlaidNot reached.
⚠️
Confirm Yes, exit — structured issue analysisDestination was not verified at runtime. Screenshot capture was unavailable.

Proposal

What is the root cause of that problem?

The personal Plaid screen uses a destinationless Navigation.goBack. The flow pushes connection methods between country selection and Plaid, so cancellation should return to connection methods—not country selection.

Evidence: PlaidBankAccountStep.tsx:49–59 supplies the callback; AccountFlowEntryPoint.tsx:70–82 opens Plaid from connection methods. These are separately registered screens, and ordinary navigation pushes rather than replaces.

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

For personal onboarding originating at country selection, make Plaid cancellation explicitly return to that existing country route, preserving its original parameters. Keep the existing fallback for entry paths without a country selector; do not change shared Plaid behavior globally.

Add a navigation regression test asserting cancellation removes both Plaid and connection methods, restores country selection, and preserves retry behavior. Also cover entry without a country selector and successful Plaid completion.

What alternative solutions did you explore?

A missing web SDK callback is unlikely: the web adapter forwards exit. Two consecutive back calls would assume a fixed stack depth and could mishandle verification screens. Returning to connection methods could be intentional, but contradicts this issue’s stated expectation.

Remaining confirmation: Reproduce using a verified account and capture the destination after cancellation. No introducing PR or production-log confirmation was established.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement this to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
⚠️

view run · view recording

MelvinBot avatar Nov 13 '26 14:11 MelvinBot

Proposal

What is the root cause of that problem?

When a user navigates to Settings > Wallet > Add bank account, selects "United States" in CountrySelection.tsx (lines 20–24) or WiseDepositAccountContent.tsx (lines 158–164), and confirms:

  1. navigateToUSBankAccountFlow(isUserValidated) is called (navigateToUSBankAccountFlow.ts:10–16).
  2. For a validated user, it navigates to createDynamicRoute(DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT_ENTRY_POINT.path, ROUTES.SETTINGS_WALLET).
  3. This pushes the AccountFlowEntryPoint screen (AccountFlowEntryPoint.tsx), which presents two connection methods: "Log into your bank" (Plaid) and "Connect manually".
  4. When the user taps "Log into your bank", handleConnectPlaid (lines 77–82) navigates to DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT with subpage PLAID_BANK_ACCOUNT, pushing AddPersonalBankAccountPage onto the stack.
  5. In PlaidBankAccountStep.tsx (PlaidBankAccountStep.tsx:57), onExitPlaid is hardcoded to Navigation.goBack:
    onExitPlaid={Navigation.goBack}
    
  6. When the user taps the exit "X" in Plaid and confirms "Yes, exit", Navigation.goBack() pops the top route (AddPersonalBankAccountPage), returning the user to its immediate parent on the navigation stack: AccountFlowEntryPoint (the "Log into your bank" / "Connect manually" page).

Because AccountFlowEntryPoint was pushed onto the navigation stack between CountrySelection and PlaidBankAccountStep, a single Navigation.goBack() naturally returns to AccountFlowEntryPoint, not CountrySelection.


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

Depending on product design intent, there are two clear paths:

Path A: If the desired behavior is to return directly to the Country Selector (ROUTES.SETTINGS_ADD_BANK_ACCOUNT)

If closing Plaid should return the user all the way back to the country selection list:

  1. In src/pages/AddPersonalBankAccountPage/substeps/PlaidBankAccountStep.tsx, update the exit handler so that when navigating back from the Plaid step, if the flow was opened from the wallet/country flow, it navigates back to ROUTES.SETTINGS_ADD_BANK_ACCOUNT (or falls back to standard Navigation.goBack() if not present):

    const handleExitPlaid = () => {
        Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT);
    };
    

    Because Navigation.goBack(backToRoute) internally calls goUp which inspects the stack using findRouteToPopTo, if ROUTES.SETTINGS_ADD_BANK_ACCOUNT is present in the stack, it will cleanly pop both AddPersonalBankAccountPage and AccountFlowEntryPoint, landing the user directly on CountrySelection. If ROUTES.SETTINGS_ADD_BANK_ACCOUNT is not in the stack (e.g., opened from a direct route or other entry points), Navigation.goBack() gracefully falls back to the previous screen.

  2. Alternatively, in src/pages/settings/Wallet/InternationalDepositAccount/subPages/AccountFlowEntryPoint.tsx, when the user selects Plaid, pass {forceReplace: true} to Navigation.navigate (or replace the route) so AccountFlowEntryPoint does not remain on the stack under Plaid.

Path B: Clarification if current behavior is intentional UX (Not A Bug / Regression Test Update)

From an architectural and UX standpoint, returning to AccountFlowEntryPoint is arguably the superior and intended design:

  • Preserves User Intent: If a user cancels Plaid because their bank is not supported or they do not wish to use online credentials, landing on AccountFlowEntryPoint immediately allows them to tap "Connect manually" without having to re-select "United States" and re-advance from the country list.
  • Consistency with Header Navigation: In AddPersonalBankAccountPage/index.tsx (line 236), tapping the header back button < executes Navigation.goBack(), which also returns to AccountFlowEntryPoint. Having Plaid exit and header back button behave consistently avoids jarring UX discrepancies.
  • Easy Traversal: The user can still return to CountrySelection at any point with a single tap of the back button < on AccountFlowEntryPoint.

If Contributor+ / BugZero confirms Path B is the intended behavior, the BrowserStack regression test case should be updated to reflect that AccountFlowEntryPoint is the expected landing screen when exiting Plaid. If Path A is preferred, Path A provides the clean, surgical fix.


What alternative solutions did you explore? (Optional)

  1. Calling Navigation.goBack() twice: Discarded because hardcoding sequential pop calls is fragile, risks race conditions during screen transitions, and fails if the user navigated to Plaid via a different entry path.
  2. Replacing CountrySelection directly when entering US flow: Discarded because users who tap the back button on AccountFlowEntryPoint need to be able to return to CountrySelection to pick a different country.

Contributor details

Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374

kevinjosh10 avatar Nov 13 '26 15:11 kevinjosh10

Proposal

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

When a user navigates to Account > Wallet > Add bank account (or Get reimbursed), selects United States on the Country Selector (Settings_Add_Bank_Account), continues through Log into your bank to open the Plaid flow, and then closes the Plaid UI (X -> Yes, exit), the app lands on the intermediate US entry-point screen (Add US bank account — Log into your bank / Connect manually) instead of returning to the Country Selector screen with United States still selected.

What is the root cause of that problem?

  1. Committed intermediate screen on the RHP stack: When the user selects United States and taps Next on the Country Selector (CountrySelection.tsx:20-24 or WiseDepositAccountContent.tsx:201-205), navigateToUSBankAccountFlow.ts:10-16 (and useDynamicForwardPath.ts:36 after OTP verification) pushes DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT_ENTRY_POINT (AccountFlowEntryPoint.tsx) onto SettingsModalStackNavigator above SCREENS.SETTINGS.ADD_BANK_ACCOUNT. Tapping Log into your bank (AccountFlowEntryPoint.tsx:77-82) then pushes DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT (AddPersonalBankAccountPage -> PlaidBankAccountStep), resulting in: [Settings_Add_Bank_Account (Country Selector), Dynamic_Add_US_Bank_Account_Entry_Point, Dynamic_Add_US_Bank_Account (Plaid)].
  2. PlaidBankAccountStep only pops a single screen on Plaid exit: In src/pages/AddPersonalBankAccountPage/substeps/PlaidBankAccountStep.tsx:57, <InputWrapper InputComponent={AddPlaidBankAccount} ... onExitPlaid={Navigation.goBack} /> passes Navigation.goBack with no target route. Confirming Yes, exit inside Plaid pops only Dynamic_Add_US_Bank_Account (pop(1)), leaving the user on AccountFlowEntryPoint instead of popping back to Settings_Add_Bank_Account.

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

Update onExitPlaid in src/pages/AddPersonalBankAccountPage/substeps/PlaidBankAccountStep.tsx to pop back to the existing SCREENS.SETTINGS.ADD_BANK_ACCOUNT route when (and only when) it is present in the current navigator stack, while preserving its backTo parameter and selectedCountry component state:

  1. Check the current stack for SCREENS.SETTINGS.ADD_BANK_ACCOUNT and pop with its exact backTo param:

    const navigation = useNavigation();
    
    const handleExitPlaid = () => {
        const countrySelectorRoute = navigation.getState()?.routes.find((route) => route.name === SCREENS.SETTINGS.ADD_BANK_ACCOUNT);
        if (countrySelectorRoute) {
            const countrySelectorBackTo = (countrySelectorRoute.params as {backTo?: Route} | undefined)?.backTo;
            Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(countrySelectorBackTo));
            return;
        }
        Navigation.goBack();
    };
    

    Pass onExitPlaid={handleExitPlaid} to <InputWrapper InputComponent={AddPlaidBankAccount} ... />.

  2. Why this exact approach avoids three subtle Navigation.goBack pitfalls:

    • ROUTES.SETTINGS_ADD_BANK_ACCOUNT is a route builder object ({route, getRoute} in src/ROUTES.ts:2688-2696), not a Route string — passing ROUTES.SETTINGS_ADD_BANK_ACCOUNT directly fails TypeScript compilation and getStateFromPath at runtime; .getRoute(...) must be called.
    • Preserves backTo and triggers an atomic StackActions.pop(distanceToPop): When opened from Wallet or BankAccountPurposePage (src/libs/actions/BankAccounts.ts:225), Settings_Add_Bank_Account carries a backTo param (e.g. backTo=/settings/wallet), and routeParamsIgnore in src/libs/Navigation/Navigation.ts:363 does not ignore backTo. Calling Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute()) without countrySelectorBackTo either fails param matching (compareParams: true -> falls into REPLACE at Navigation.ts:617, duplicating the Country Selector on top of AccountFlowEntryPoint) or, with {compareParams: false}, dispatches POP_TO (Navigation.ts:626), overwriting backTo on the existing route. Matching countrySelectorBackTo hits StackActions.pop(distanceToPop) (Navigation.ts:636), cleanly popping both US screens and revealing the already-mounted Country Selector with United States selected and its original backTo intact.
    • Does not hijack direct US bank setup entry points: When PlaidBankAccountStep is reached directly without the Country Selector on the stack (e.g., ROUTES.BANK_ACCOUNT_PERSONAL or openPersonalBankAccountSetupView({shouldSetUpUSBankAccount: true}) in BankAccounts.ts:222), countrySelectorRoute is undefined, so handleExitPlaid falls back to Navigation.goBack() instead of REPLACE-navigating into the Wallet Country Selector.
  3. Add a unit test covering PlaidBankAccountStep onExitPlaid both when SCREENS.SETTINGS.ADD_BANK_ACCOUNT (with backTo) is in the stack and when entered directly without SCREENS.SETTINGS.ADD_BANK_ACCOUNT.

(Note on product/QA expectation: If Product instead considers landing on AccountFlowEntryPoint intentional after PRs introducing the US entry-point chooser—so a user exiting Plaid can immediately pick Connect manually without re-selecting United States—then BrowserStack test case #41236749 should be updated rather than changing onExitPlaid. Otherwise, the stack-aware handleExitPlaid above restores the exact expected Country Selector behavior safely across all entry points.)

What alternative solutions did you explore?

  1. Using {forceReplace: true} when navigating from AccountFlowEntryPoint to AddPersonalBankAccountPage: Rejected because pressing the header Back button on ManualBankAccountDetailsStep (or PlaidBankAccountStep before opening Plaid) uses useDynamicBackPath(DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT.path) (AddPersonalBankAccountPage/index.tsx:168), which intentionally returns the user to AccountFlowEntryPoint so they can switch between Log into your bank and Connect manually.
  2. Unconditionally calling Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute()): Rejected because when SCREENS.SETTINGS.ADD_BANK_ACCOUNT is absent from the stack (or has a backTo query parameter), goUp (Navigation.ts:617) performs REPLACE instead of popping—corrupting the stack or redirecting non-Wallet callers to the Country Selector.

cocvn157 avatar Nov 13 '26 16:11 cocvn157

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~014898525b9c53fc32

Proposal

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

When a user navigates to Account > Wallet > Add bank account, taps Get reimbursed, selects United States from the country selector, taps Log into your bank to open Plaid, and then closes the Plaid modal (X -> Yes, exit), the user does not land back on the country selector. Instead, they land on the intermediate SetupMethod ("Add bank account") screen.

What is the root cause of that problem?

In src/pages/EnablePayments/Wallet/AddBankAccount/substeps/PlaidStep.tsx:74:

<InputWrapper
    InputComponent={AddPlaidBankAccount}
    ...
    onExitPlaid={clearPersonalBankAccountSetupType}
/>
  1. When Plaid is exited via onExitPlaid, PlaidStep calls clearPersonalBankAccountSetupType, which resets setupType in ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM_DRAFT to null.
  2. In AddBankAccount.tsx:183, isSetupTypeChosen evaluates to false because setupType is null. Rather than popping the navigation stack back to the country selection screen (CountrySelectionStep in Settings_Add_Bank_Account route), AddBankAccount renders the inline SetupMethod.tsx component within the current screen.
  3. In contrast, in src/pages/AddPersonalBankAccountPage/substeps/PlaidBankAccountStep.tsx:57, onExitPlaid is correctly wired to Navigation.goBack:
    onExitPlaid={Navigation.goBack}
    
    Because PlaidStep.tsx calls clearPersonalBankAccountSetupType instead of popping the route via Navigation.goBack(), the user remains trapped in AddBankAccount on the SetupMethod view instead of returning to the country selector.

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

  1. Wire Navigation.goBack on Plaid exit in src/pages/EnablePayments/Wallet/AddBankAccount/substeps/PlaidStep.tsx:74: Update onExitPlaid to dismiss and pop back to the previous screen (the country selector) while cleaning up setup state:

    onExitPlaid={() => {
        clearPersonalBankAccountSetupType();
        Navigation.goBack();
    }}
    

    Or align directly with PlaidBankAccountStep.tsx:57:

    • If arriving from CountrySelection (where Navigation.navigate(ROUTES.SETTINGS_ADD_BANK_ACCOUNT) or navigateToUSBankAccountFlow pushed the route), Navigation.goBack() pops back to the country selector.
    • Clear any pending Plaid errors via clearPersonalBankAccountErrors().
  2. Handle back press from SetupMethod.tsx / AddBankAccount.tsx:152-155: Ensure handleBackButtonPress in AddBankAccount.tsx pops back to ROUTES.SETTINGS_ADD_BANK_ACCOUNT (Country Selector) if the user arrived via the international country selection flow rather than unconditionally exiting to ROUTES.SETTINGS_WALLET.

  3. Automated tests:

    • In tests/unit/PlaidStepTest.tsx: Verify that invoking onExitPlaid triggers Navigation.goBack and cleans up setup draft state.
    • In tests/unit/AddBankAccountTest.tsx: Test that exiting Plaid when arriving from the country selector restores the country selector view without rendering the stuck SetupMethod screen.

What alternative solutions did you explore? (Optional)

  • Only resetting setupType: null without calling Navigation.goBack(): Rejected because that is the exact current behavior that traps the user on SetupMethod.

RajGahoi avatar Nov 14 '26 18:11 RajGahoi

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

melvin-bot[bot] avatar Nov 14 '26 18:11 melvin-bot[bot]

Proposal

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

On Settings > Wallet > Add bank account, a policy admin taps Get reimbursed, lands on the country list ("Where's your bank account located?"), selects United States, taps Next, then Log into your bank. Closing the Plaid UI (X → Yes, exit) should return the user to that same country list, with United States still selected. Instead they land on the intermediate "Log into your bank" / "Connect manually" screen.

This is the same expected result as the earlier, already-fixed issue #54737. It reproduces on Android and web because both Plaid adapters call onExit() with no arguments; this is not a missing web SDK callback.

What is the root cause of that problem?

Plaid cancellation only pops one screen, and the US flow now has an extra screen between the country list and Plaid.

For a policy admin, Wallet > Add bank account opens ROUTES.SETTINGS_BANK_ACCOUNT_PURPOSE. Get reimbursed then calls openPersonalBankAccountSetupView({}), which navigates to the country list with the purpose page as backTo:

        Navigation.navigate(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(Navigation.getActiveRoute()));

SCREENS.SETTINGS.ADD_BANK_ACCOUNT is InternationalDepositAccount. With the WISE_REIMBURSEMENTS beta it renders WiseDepositAccountContent; otherwise it renders the Corpay country list. Both treat United States (and PR, GU, VI via COUNTRIES_US_BANK_FLOW) as a jump into the US flow, and neither writes the selected country to Onyx or the form draft before leaving:

        if (COUNTRIES_US_BANK_FLOW.includes(selectedCountry)) {
            navigateToUSBankAccountFlow(isUserValidated);
            return;
        }
    const onCountrySelected = () => {
        if (COUNTRIES_US_BANK_FLOW.includes(selectedCountry)) {
            navigateToUSBankAccountFlow(isUserValidated);
            return;
        }

selectedCountry therefore lives only in React state on the already-mounted country screen. A later remount reinitializes it from wiseBankAccountFields?.country ?? country (Wise) or formValues.bankCountry (Corpay), which may not be United States.

For a validated user, navigateToUSBankAccountFlow always appends the entry-point suffix to settings/wallet, not to the country-list route. That is required because DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT_ENTRY_POINT.entryScreens is only [SCREENS.SETTINGS.WALLET.ROOT]:

function navigateToUSBankAccountFlow(isUserValidated: boolean | undefined) {
    if (isUserValidated) {
        Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT_ENTRY_POINT.path, ROUTES.SETTINGS_WALLET));
        return;
    }
    Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.VERIFY_ACCOUNT.path));
}

The country list, entry point, and Plaid page are all screens in the same SCREENS.RIGHT_MODAL.SETTINGS stack (src/libs/Navigation/linkingConfig/config.ts). After Next, that stack is:

[…, Settings_Bank_Account_Purpose, Settings_Add_Bank_Account (country list, still mounted), Dynamic_Settings_Add_US_Bank_Account_Entry_Point, …]

Log into your bank then pushes DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT (AccountFlowEntryPoint.tsx lines 77–82). PlaidBankAccountStep wires cancellation to a destinationless back:

                onExitPlaid={Navigation.goBack}

Web (src/components/PlaidLink/index.tsx lines 39–42) and native (BaseNativePlaidLink.tsx lines 24–26) both invoke onExit() with no args, so this is a plain pop(1). The user lands on AccountFlowEntryPoint, not the country list.

This is also why a naive Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT) is unsafe even after calling .getRoute():

  • ROUTES.SETTINGS_ADD_BANK_ACCOUNT is a {route, getRoute} builder (src/ROUTES.ts lines 2706–2715), not a path string.
  • goUp compares params by default, and routeParamsIgnore in src/libs/Navigation/Navigation.ts (line 363) does not ignore backTo.
  • On the reported path, backTo is settings/wallet/bank-account-purpose. A non-admin opening the country list from Wallet, or a KYC / queued-reimbursement entry, will have a different backTo. getRoute() with a missing or wrong backTo fails the param match, so canPopToRoute is false and goUp replaces the current screen (Navigation.ts lines 617–620) instead of popping. That remounts the country list and can drop the United States selection, or it can leave the entry-point screen underneath.
  • {compareParams: false} would POP_TO and overwrite the existing backTo.

If the user was not yet validated, navigateToUSBankAccountFlow first opens verify-account. After the magic code, useDynamicForwardPath.ts (line 36) forwards to the same wallet entry-point route. Popping back to the already-mounted country route still has to remove the entry point and Plaid, and any leftover verify-account screen, in one param-matching pop.

This is not the Enable Payments / KYC flow (src/pages/EnablePayments/Wallet/AddBankAccount/substeps/PlaidStep.tsx, which calls clearPersonalBankAccountSetupType and falls back to an inline SetupMethod view). That path never shows this country list.

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

Update onExitPlaid in src/pages/AddPersonalBankAccountPage/substeps/PlaidBankAccountStep.tsx only. Leave the header back button on AddPersonalBankAccountPage (line 236) as a plain Navigation.goBack(), so a user who is already on the Plaid account picker can still return to Log into your bank / Connect manually.

  1. On Plaid cancel, pop to the existing country-list route when it is in the Settings RHP stack, using that route's exact backTo. Look up SCREENS.SETTINGS.ADD_BANK_ACCOUNT by walking the navigation state (the Settings modal stack under SCREENS.RIGHT_MODAL.SETTINGS, not only useNavigation().getState().routes, so a nested or parent navigator cannot miss it). If it is present:
const handleExitPlaid = () => {
    const countrySelectorRoute = findSettingsAddBankAccountRoute();
    if (countrySelectorRoute) {
        const countrySelectorBackTo = (countrySelectorRoute.params as {backTo?: Route} | undefined)?.backTo;
        Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(countrySelectorBackTo));
        return;
    }
    Navigation.goBack();
};

That hits StackActions.pop(distanceToPop) in goUp (Navigation.ts line 636), removes both the Plaid screen and AccountFlowEntryPoint (and a leftover verify-account screen, if any), and reveals the already-mounted country list with United States still selected and its original backTo intact.

  1. If the country list is not on the stack, keep today's Navigation.goBack(). Direct US setup — openPersonalBankAccountSetupView({shouldSetUpUSBankAccount: true}) or ROUTES.BANK_ACCOUNT_PERSONAL — never pushed Settings_Add_Bank_Account, and must not be redirected into the Wallet country list.

Do not {forceReplace: true} when opening Plaid from AccountFlowEntryPoint. That would also make the header back button skip the method chooser, so the user could not switch to Connect manually without re-selecting the country.

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

  • Policy-admin path from Get reimbursed: stack is purpose → country list (backTo=settings/wallet/bank-account-purpose) → entry point → Plaid. onExitPlaid pops to the existing Settings_Add_Bank_Account route, and the United States row is still selected (the screen was not remounted).
  • Non-admin Wallet path: same pop, but the country list's backTo is the Wallet route from openPersonalBankAccountSetupView.
  • Unvalidated path: after magic-code verification forwards to the entry point, Plaid cancel still pops to the existing country list rather than remounting it or leaving verify-account on top.
  • Direct US setup with no Settings_Add_Bank_Account on the stack falls back to a single Navigation.goBack().
  • Header back on the first subpage of AddPersonalBankAccountPage still returns to AccountFlowEntryPoint, so Connect manually remains reachable.
  • Successful Plaid completion is unchanged.

What alternative solutions did you explore? (Optional)

  • Leave the user on AccountFlowEntryPoint and update the BrowserStack case. Rejected because the issue's expected result, and the earlier #54737 contract, is the country list with United States still selected. The method chooser remains one header-back press away if the user really wants Connect manually.
  • Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT) or getRoute() without the existing backTo. Rejected because the first is a route builder, not a path, and the second fails param matching and can REPLACE / remount the list, losing the in-memory United States selection.
  • Two raw goBack() calls, or {forceReplace: true} when opening Plaid. Rejected as fragile across the unvalidated and direct-US entry paths, and because replace would break header-back to the method chooser.
  • Change EnablePayments PlaidStep / SetupMethod. Rejected because that is a different flow and is not what these reproduction steps open.

PawanOzha avatar Nov 15 '26 03:11 PawanOzha

📣 @PawanOzha! 📣 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:

  1. Make sure you've read and understood the contributing guidelines.
  2. 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.
  3. 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.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Nov 15 '26 03:11 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01e1700af765e4270c

PawanOzha avatar Nov 15 '26 04:11 PawanOzha

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

melvin-bot[bot] avatar Nov 15 '26 04:11 melvin-bot[bot]

Proposal

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

When a user navigates to Account > Wallet > Add bank account > Get reimbursed, selects United States on the Country Selector (Settings_Add_Bank_Account), taps Next, taps Log into your bank (AccountFlowEntryPoint), and then closes the Plaid UI (X -> Yes, exit), the user lands on the intermediate US method-selection screen (AccountFlowEntryPoint: Log into your bank / Connect manually) instead of returning to the Country Selector screen with United States selected.

What is the root cause of that problem?

  1. AccountFlowEntryPoint sits on the SettingsModalStackNavigator stack between the Country Selector and Plaid:
    • Selecting United States on the Country Selector (src/pages/settings/Wallet/InternationalDepositAccount/subPages/CountrySelection.tsx:20-24 or WiseDepositAccountContent.tsx:201-205) calls navigateToUSBankAccountFlow(isUserValidated) (src/pages/settings/Wallet/InternationalDepositAccount/navigateToUSBankAccountFlow.ts:10-16), which pushes DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT_ENTRY_POINT (AccountFlowEntryPoint.tsx) onto SettingsModalStackNavigator above SCREENS.SETTINGS.ADD_BANK_ACCOUNT.
    • Tapping Log into your bank (AccountFlowEntryPoint.tsx:77-82) pushes DYNAMIC_ROUTES.ADD_US_BANK_ACCOUNT (AddPersonalBankAccountPage -> PlaidBankAccountStep), creating the stack: [..., Settings_Add_Bank_Account (Country Selector), Dynamic_Settings_Add_US_Bank_Account_Entry_Point, Dynamic_Settings_Add_US_Bank_Account (Plaid)].
  2. PlaidBankAccountStep passes a destinationless Navigation.goBack to onExitPlaid (src/pages/AddPersonalBankAccountPage/substeps/PlaidBankAccountStep.tsx:57):
    • Both the web (src/components/PlaidLink/index.tsx:39-42) and native (BaseNativePlaidLink.tsx:24-26) Plaid adapters invoke onExit() with no arguments.
    • Navigation.goBack() pops only 1 screen (Dynamic_Settings_Add_US_Bank_Account), leaving the user on AccountFlowEntryPoint instead of popping back to the mounted Settings_Add_Bank_Account Country Selector.

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

  1. Update onExitPlaid in src/pages/AddPersonalBankAccountPage/substeps/PlaidBankAccountStep.tsx to pop back to the existing SCREENS.SETTINGS.ADD_BANK_ACCOUNT route with its exact backTo parameter when present on the stack:
    const navigation = useNavigation();
    
    const handleExitPlaid = () => {
        const countrySelectorRoute = navigation.getState()?.routes.find((route) => route.name === SCREENS.SETTINGS.ADD_BANK_ACCOUNT);
        if (countrySelectorRoute) {
            const countrySelectorBackTo = (countrySelectorRoute.params as {backTo?: Route} | undefined)?.backTo;
            Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(countrySelectorBackTo));
            return;
        }
        Navigation.goBack();
    };
    
    Pass onExitPlaid={handleExitPlaid} to <InputWrapper InputComponent={AddPlaidBankAccount} ... /> (line 57).
  2. Why preserving countrySelectorBackTo and checking the stack is critical:
    • When opened via Get reimbursed, openPersonalBankAccountSetupView (src/libs/actions/BankAccounts.ts:225) navigates to ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(Navigation.getActiveRoute()), attaching a backTo parameter (settings/wallet/bank-account-purpose or settings/wallet).
    • In src/libs/Navigation/Navigation.ts:363, 617-636, goUp compares route params (backTo is not in routeParamsIgnore). Calling Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute()) without countrySelectorBackTo fails param matching and executes REPLACE (line 617), which remounts the Country Selector and loses its in-memory selectedCountry = 'US' React state.
    • Passing ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(countrySelectorBackTo) matches the mounted route's params and dispatches StackActions.pop(distanceToPop) (line 636), cleanly popping both Dynamic_Settings_Add_US_Bank_Account and Dynamic_Settings_Add_US_Bank_Account_Entry_Point (plus any intermediate verify-account route) while keeping the mounted Country Selector's United States selection and backTo intact.
    • When PlaidBankAccountStep is entered directly without the Country Selector in the stack (e.g. openPersonalBankAccountSetupView({shouldSetUpUSBankAccount: true}) or ROUTES.BANK_ACCOUNT_PERSONAL), countrySelectorRoute is undefined and handleExitPlaid falls back to Navigation.goBack().
  3. Add unit tests verifying onExitPlaid in PlaidBankAccountStep both when SCREENS.SETTINGS.ADD_BANK_ACCOUNT (with backTo) is in the stack and when entered directly.

What alternative solutions did you explore? (Optional)

  • Passing {forceReplace: true} when navigating from AccountFlowEntryPoint to AddPersonalBankAccountPage: Discarded because pressing the header Back button < on AddPersonalBankAccountPage (line 236) or ManualBankAccountDetailsStep should still return to AccountFlowEntryPoint so the user can switch to Connect manually.
  • Calling Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute()) unconditionally: Discarded because a mismatched backTo param triggers REPLACE (losing the in-memory United States selection) and redirects direct US bank setup flows into the Country Selector.

U-ITACHII avatar Nov 15 '26 22:11 U-ITACHII

@MelvinBot please revise your proposal at https://github.com/Expensify/App/issues/106857#issuecomment-6856274071 and post the revision as its own comment, outside the test-step table.

I think the root cause is backwards. A destinationless Navigation.goBack in PlaidBankAccountStep pops one screen, and AccountFlowEntryPoint sits between the country list and Plaid, so cancel lands on "Log into your bank" / "Connect manually". That is the bug. The expected result is the country list with United States still selected.

On Plaid cancel only, when Settings_Add_Bank_Account is already on the Settings stack, go back to that route rebuilt with its existing backTo. A missing or different backTo makes goUp replace the screen and drop the in-memory selection. If that route is absent, keep a plain Navigation.goBack. Leave the header back button as a single goBack, and do not change shared Plaid behavior. What do you think?

mananjadhav avatar Nov 15 '26 22:11 mananjadhav

Agreed—my earlier explanation reversed actual and expected behavior. This replaces the previous proposal.

Proposal

What is the root cause of that problem?

Plaid cancellation uses a destinationless Navigation.goBack, which pops one screen. Because AccountFlowEntryPoint sits between the country list and Plaid, cancellation returns to “Log into your bank” / “Connect manually”. That is the bug: it should reveal the existing country list with United States still selected.

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

Change only the personal-bank Plaid cancellation handler:

  1. Look for the existing Settings_Add_Bank_Account route in the active Settings stack.
  2. If present, call Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(existingBackTo)), using that route’s existing backTo.
  3. If absent, retain plain Navigation.goBack().

Preserving backTo matters: a missing or different value prevents parameter matching, causing goUp to replace rather than pop to the existing screen. That can lose the country list’s in-memory selection.

Leave the header back button as one goBack and make no shared Plaid changes.

Regression coverage should verify:

  • Cancel restores the existing country list with United States selected and its original backTo.
  • Direct US setup without a country-list route retains ordinary back behavior.
  • Header back still reaches the method chooser.
  • Successful Plaid completion remains unchanged.
Supporting code evidence

This revision is code-validated; Plaid cancellation has not been verified at runtime.

What alternative solutions did you explore? (Optional)

  • Unconditionally target the country route: unsafe when absent or when backTo differs.
  • Two back calls: assumes a fixed stack depth.
  • Replace the method chooser: changes header-back behavior.
  • Change shared Plaid behavior: unnecessarily affects other flows.

Next Steps for Contributor+ team:
To accept: @MelvinBot implement this proposal to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.


view run

MelvinBot avatar Nov 15 '26 22:11 MelvinBot

@MelvinBot implement this proposal

mananjadhav avatar Nov 15 '26 22:11 mananjadhav

🤖 Web test steps verification results: ❌ fail

Blocked on dev NewDot web: the existing browser rendered no UI, and no app tool session was available. None of the requested bank-flow behaviors could be verified.

Blank app preventing access to Wallet
Step Status
Plaid exit restores the country list with United States selectedBlocked: browser snapshots returned zero nodes; waiting for Wallet timed out.
Blank app preventing access to Wallet
❌
Header back returns to the method chooserNot verified because the app UI was unavailable.
❌
Direct US setup cancellation retains ordinary back behaviorNot verified because the app UI was unavailable.
❌

Implemented in Preserve country selection when canceling personal bank Plaid, created as a draft and assigned to mananjadhav. Header back and shared Plaid behavior remain unchanged.

Checks: 51 targeted tests, lint, typecheck, compiler check, formatting, spelling, and Storybook smoke test passed. Full Jest run timed out after 10 minutes. Manual Tests/QA and successful Plaid completion verification remain outstanding.


view run · no recording available

MelvinBot avatar Nov 15 '26 23:11 MelvinBot

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

@mananjadhav Still overdue 6 days?! Let's take care of this!

PR marked ready for review.

mananjadhav avatar Nov 24 '26 18:11 mananjadhav