Skip to content

[Due for payment 2026-09-17] Add BA"Validate your bank account" is not opened instantly after clicking pending BA #99998

Closed

Description

@applause-bot

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


Version Number: v9.4.65-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://test-management.browserstack.com/projects/2219752/folder/54018437/test-cases/41236758
Email or phone of affected tester (no customers): applausetester+ds@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Mac 14.5/ Chrome
App Component: Workspace Settings

Action Performed:

  1. Sign in to ND with Expensifail account
  2. Create a workspace
  3. Go to Workspace settings - Workflows - Add bank account
  4. Start adding a bank account via "Connect manually" option
  5. On the final step click "Continue", "Validate your bank account" page is displayed
  6. Navigate to Workflows, click the pending bank account
  7. Verify that RHP "Validate your bank account" instantly opens

Expected Result:

"Validate your bank account" instantly opens

Actual Result:

Continue setup and Start over buttons appear

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7247728_1788246773116.Screen_Recording_2026-09-01_at_10.10.09_in_the_morning.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7247728

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. applause-bot commented on Sep 1, 2026

    @applause-bot
    Author

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

  2. added
    Bug
    on Sep 1, 2026
  3. added
    Internal
    on Sep 1, 2026
  4. MelvinBot commented on Sep 1, 2026

    @MelvinBot
    Contributor

    Proposal

    This is a regression of #93564. That issue was fixed by #94707 on 2026-07-10, and the fix was reverted five days later by #96182 because it caused deploy blocker #96130 ("Wallet - Blank RHP is shown after adding a Bank Account"). It was never re-landed.

    What is the root cause of that problem?

    The code that is supposed to skip the "Continue setup / Start over" screen for a pending USD bank account is dead code. It sets a state variable that nothing renders any more.

    ReimbursementAccountPage.tsx:361-367 still says "If USD bank account is in pending state, we should navigate straight to the validation step and skip Continue step", but none of its three statements does that today:

    1. setUSDBankAccountStep(VALIDATION) — USDBankAccountStep is now write-only. No render path reads it; the only read in the file is a self-comparison at line 371.
    2. goToWithdrawalAccountSetupStep(VALIDATION) — despite the name it performs no navigation. It is a single Onyx.merge of achData.currentStep (navigation.ts:13-15).
    3. setShouldShowContinueSetupButton(...) sets the flag to true, because hasInProgressUSDVBBA returns true for every state that is not OPEN or LOCKED — including PENDING.

    Execution then falls through to the page's terminal render at line 653, which passes shouldShowContinueSetupButton = true into VerifiedBankAccountFlowEntryPoint.tsx:285 — the "Continue setup / Start over" screen the tester saw.

    The branch broke in #86645 ([CBN] USD flow refactor, commit 3dc75a95), which moved the USD flow onto its own route and deleted the render branch that consumed USDBankAccountStep, but left this call site behind. No type error, no lint error — the behaviour just silently stopped.

    Supporting evidence and history

    The Workflows entry point is not at fault. WorkflowsPaymentsTab.tsx:206-209 calls navigateToBankAccountRoute({policyID, backTo}) — byte-identical to the "Add bank account" call at line 358. No entry point in the app passes a param that opens the validate step directly, and nothing on the stepToOpen path clears shouldShowContinueSetupButton.

    The state is PENDING, not VALIDATING. CONST.BANK_ACCOUNT.STATE.VALIDATING is declared but never referenced anywhere in src/. The "Validate your bank account" title and micro-deposit form are gated on PENDING in ConnectBankAccount.tsx.

    Timeline

    Date PR Effect
    2025-10-06 #71898 Added the PENDING skip branch. Worked — the page rendered the USD flow inline.
    2026-04-09 #86645 (3dc75a95) USD flow moved to per-step routes; the inline render branch reading USDBankAccountStep was deleted. Branch became dead code.
    2026-06-05 #92773 Added the setShouldShowContinueSetupButton line; its description explicitly accepted showing the interstitial.
    2026-07-10 #94707 Real fix for #93564 — navigated directly to the validation page.
    2026-07-15 #96182 Reverted #94707 over deploy blocker #96130. Never re-landed.

    Why the previous fix caused #96130 (inferred, not runtime-verified). To make the validation page work when reached directly, #94707 also re-sourced state from BANK_ACCOUNT_LIST instead of achData. When policyID was absent or the list had not refreshed, bankAccountState became '', so neither the pending nor the verifying branch matched and the RHP rendered header-only — blank. It needed that change because only ReimbursementAccountPage calls openReimbursementAccountPage; bypassing that page leaves achData empty.

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

    Replace the three no-op statements in ReimbursementAccountPage.tsx:361-367 with a real redirect to ROUTES.BANK_ACCOUNT_USD_SETUP at page VALIDATION, performed from inside ReimbursementAccountPage after its fetch completes rather than at the caller.

    Doing the redirect in-page is what avoids repeating #96130: openReimbursementAccountPage still runs, so achData.state is populated and ConnectBankAccount can keep reading it. No changes to ConnectBankAccount.tsx or BankAccountValidationForm.tsx are needed.

    Three details the implementer must handle:

    1. Gate on hasLoadedData and on not being in the change-bank-account flow, so the redirect fires only once real achData has arrived.
    2. Latch it with a useRef. The back handler in USDVerifiedBankAccountFlowPage.tsx sends VALIDATION+PENDING back-presses to BANK_ACCOUNT_WITH_STEP_TO_OPEN, so an unlatched effect would bounce the user straight back into validate.
    3. Use forceReplace so the interstitial stays out of the back stack. Both screens are siblings in the same RHP navigator, so Back lands on Workflows as expected.

    What alternative solutions did you explore? (Optional)

    • Navigate straight to BANK_ACCOUNT_USD_SETUP?page=validation from WorkflowsPaymentsTab. Rejected — this is essentially what Open validation RHP directly for pending USD bank accounts #94707 did. USDVerifiedBankAccountFlowPage does no fetching of its own, so bypassing ReimbursementAccountPage leaves achData empty and reproduces the blank-RHP deploy blocker.
    • Make hasInProgressUSDVBBA return false for PENDING. Rejected — hasInProgressVBBA also gates shouldShowContinueModal and the "connect existing account" branches in WorkflowsPaymentsTab, so this would change unrelated behaviour.
    • Re-land Open validation RHP directly for pending USD bank accounts #94707 as-is. Rejected — it was reverted for a reason and its BANK_ACCOUNT_LIST-derived state changes are the part that broke.
    Reproduction attempt on web

    I tried to reproduce this on web and was blocked before reaching the bank form. Clicking Connect manually immediately presented a "Validate your account" screen asking for a 6-digit security code emailed to the test account, which the automated tester cannot retrieve.

    Step Status Observation
    Workspace created pass New workspace created and Overview shown.
    Workflows → Add bank account → Connect manually pass "Streamline payments" panel opened; "Connect manually" clicked.
    Complete manual bank account flow to final Continue fail Blocked by an email magic-code "Validate your account" gate before any routing/account number fields appeared.
    "Validate your bank account" page displayed fail Never reached.
    Pending bank account row opens validate instantly fail Not attempted — no bank account was created.

    The analysis above therefore rests on code and git history, not a live repro. The defect is deterministic client-side render logic, and #93564 documents the identical user-visible behaviour, so confidence remains high.

    Validate your account screen (6-digit email code) blocking the manual bank account connect flow

    Validate your account screen (6-digit email code) blocking the manual bank account connect flow

    Related issues


    💡 Suggested AI code review rule

    This bug looks like a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for Expensify/App:

    • Rule: CONSISTENCY-19 — Never leave state that is written but never read
    • Condition: Flag a useState value whose getter is never read by a render path or by any logic other than a guard around its own setter — especially when a PR deletes a component usage or render branch and leaves the corresponding setX(...) calls behind. Either delete the state and its writes, or restore a reader.
    • Why: The write silently no-ops, so a behavioural branch becomes dead code with no type or lint error. Here it turned "skip the Continue setup step for pending USD bank accounts" into a permanent regression that shipped twice.
    • Search pattern: for each const [X, setX] = useState( in a changed file, count references to X excluding the declaration and setX; flag when the only remaining reference is a condition that guards a setX call.
    • Offending code (❌): ReimbursementAccountPage.tsx:361-367
    • Fix (✅): replace the dead writes with a real Navigation.navigate to the validation page, as described above.

    This is distinct from CONSISTENCY-4 (No unused props), which covers props rather than component state. The full rule file, with the ❌/✅ code inline in App's coding-standards format, would go in Expensify/App itself. If it's worth adding, a maintainer can open it there as a draft PR.


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


    view run

  5. added
    External
    on Sep 1, 2026
  6. j3ffffff commented on Sep 1, 2026

    @j3ffffff
  7. melvin-bot commented on Sep 1, 2026

    @melvin-bot

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

  8. melvin-bot commented on Sep 1, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  9. ikevin127 commented on Sep 2, 2026

    @ikevin127
    Contributor

    @MelvinBot Thanks, the root cause analysis holds up. I verified every claim against the tree before acting on it: USDBankAccountStep really is write-only, goToWithdrawalAccountSetupStep really is just an Onyx.merge, and hasInProgressUSDVBBA really does return true for PENDING. That part is solid, and it is why I implemented this locally rather than sending it back on paper.

    I then ran the proposed solution end to end against a pending USD account. It does not work as written. Two of the failures are the exact things the proposal claims to avoid, and one of them is #96130 reproduced. Please update the proposal to cover the following:

    ⚠️ Issues with the initial proposal

    🔴 forceReplace reproduces #96130. forceReplace sets the action to REPLACE (linkTo/index.ts:197-199), which pops ReimbursementAccountPage and unmounts it. Its own unmount cleanup (ReimbursementAccountPage.tsx:192-199) calls clearReimbursementAccount(), which is Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT, CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA). DEFAULT_DATA.achData is {state: 'SETUP'} with no bankAccountID, so ConnectBankAccount matches none of its render branches and shows a header-only blank RHP titled "Add bank account". The proposal's reasoning accounts for the fetch but not the teardown: the page fetches the data and then, by replacing itself, destroys it. This must be a push.

    🔴 An effect-only redirect cannot satisfy the expected result. Effects run after paint, so the entry point renders with shouldShowContinueSetupButton true for at least one frame before the navigation lands. The observed sequence was loading, then "Continue setup / Start over", then validate. That middle screen is precisely the issue's Actual Result, so the bug is not fixed, only made faster. The condition has to be derived during render and used to short-circuit the render as well, returning ReimbursementAccountLoadingIndicator instead of VerifiedBankAccountFlowEntryPoint.

    🔴 The page's own teardown is hostile to any handoff, not just to forceReplace. Even with a push, on a cold load (browser refresh, then re-enter from Workflows) this page can unmount after the redirect has already dispatched, and the same clearReimbursementAccount() wipes the data out from under ConnectBankAccount. Same blank RHP, different trigger. The cleanup has to skip the wipe when the instance is unmounting only because it redirected into the validation step of the same flow. This is the part that most undermines the proposal's central claim: redirecting in-page does not by itself avoid #96130.

    🟠 The fix does not fit in one file. Once this page reliably redirects a pending account, USDVerifiedBankAccountFlowPage.tsx:136-137 becomes a loop: it sends a VALIDATION plus PENDING back press to BANK_ACCOUNT_WITH_STEP_TO_OPEN, which is this page, which redirects again. It has to leave the flow instead, using backTo with a Navigation.dismissModal() fallback for entry points where backTo is absent, since Navigation.goBack(undefined) would pop straight back onto the redirector. Worth noting this is not a new contract: goBack in ReimbursementAccountPage.tsx:602-606 already calls Navigation.closeRHPFlow() for STEP.VALIDATION with STATE.PENDING. The change makes the USD flow page agree with what this file already does.

    🟠 The useRef latch has to be split in two. A single latch cannot tell "the redirect is in flight and we are still on top" from "the user has navigated back onto us", because it flips synchronously while the page is still focused. The browser back button is not covered by the back handler above, and it exposed this: the render guard stayed true while the once-per-mount latch blocked any further navigation, so the page sat on the loading indicator forever. A second ref recording whether the page has actually been blurred is needed, plus an effect declared after the redirect effect so it does not race the navigation it follows.

    🟡 Guard on policyID. REIMBURSEMENT_ACCOUNT is persisted, so on a cold load achData can still describe a different policy's account. hasInProgressVBBA already guards this (ReimbursementAccountUtils.ts:38-40) and so does the isPreviousPolicy check on the effect, but a render-derived condition needs it too. This becomes load-bearing once the cleanup skip keeps stale data around longer.

    🟡 CONST.BANK_ACCOUNT.STEP.VALIDATION is not the route page name. STEP.VALIDATION is 'ValidationStep' but PAGE_NAMES.VALIDATION is 'validation'. The dead code being replaced uses the STEP constant, so "at page VALIDATION" leads an implementer to build bank-account/new/us/ValidationStep, which matches no page entry and silently falls back to index 0, the Country page. Use CONST.BANK_ACCOUNT.PAGE_NAMES.VALIDATION, and forward backTo, which the proposal also drops.

    🟡 Please address the existing stepToOpen mechanism explicitly. getStepToOpenFromRouteParams already maps VALIDATE: 'validate' to CONST.BANK_ACCOUNT.STEP.VALIDATION, and ConnectExistingBusinessBankAccountPage.tsx:70 shows the idiomatic way to pass it via appendParam. I checked and it does not solve this, because since #86645 this page has no inline step rendering left and only renders VerifiedBankAccountFlowEntryPoint, so a navigation is still required. But a proposal bypassing existing infrastructure should say why.

    One smaller note: removing goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.VALIDATION) also removes a real Onyx.merge of achData.currentStep that other code reads, including the stepToPageName map in continueUSDVBBASetup at line 501 and the goBack switch. It tested fine, but please describe it as a behaviour change rather than listing all three statements as pure no-ops.

    Working diff, verified locally against a pending USD account

    Tested on web. Entry from Workflows opens the validation step with no interstitial frame; in-app back and browser back both return to Workflows; the cold-load path (refresh on another tab, then re-enter from Workflows) no longer blanks; and non-pending accounts (VERIFYING, OPEN, fresh setup, non-USD, change bank account) are unaffected. Typechecks clean.

    Not verified locally: the actual micro-deposit submit. My repro forces the client state, so ValidateBankAccountWithTransactions 404s against an account the backend does not consider pending.

    The diff does not touch BankAccountValidationForm or validateBankAccount, and the bankAccountID sent is unchanged, but that round trip needs a genuinely pending account and should be an explicit acceptance criterion.

    diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
    --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
    +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
    @@ -121,6 +121,12 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
         const hasClearedStalePlaidErrorsRef = useRef(false);
         const isChangingBankAccountRef = useRef(isChangingBankAccount);
         const hasShownConnectedBankAccountRef = useRef(false);
    +    // Latches the pending-USD redirect below so the effect dispatches the navigation at most once per mount, even
    +    // though its dependencies change again while the transition is in flight.
    +    const hasRedirectedToPendingValidationRef = useRef(false);
    +    // Set once this page has actually been covered by the validation step. The redirect ref alone cannot tell that
    +    // apart from the redirect still being in flight, because it flips while this page is still focused.
    +    const hasBlurredAfterPendingRedirectRef = useRef(false);
         const prevReimbursementAccount = usePrevious(reimbursementAccount);
         const prevIsOffline = usePrevious(isOffline);
         const achData = reimbursementAccount?.achData;
    @@ -184,7 +190,10 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
         useEffect(() => {
             const isChangingBankAccountInstance = isChangingBankAccountRef.current;
             return () => {
    -            if (!isChangingBankAccountInstance) {
    +            // Don't wipe the account when this instance unmounts only because it redirected into the validation step of
    +            // the same flow. ConnectBankAccount reads achData.state and does no fetching, so clearing here resets it to
    +            // DEFAULT_DATA underneath it and renders a blank header-only RHP (Expensify/App#96130).
    +            if (!isChangingBankAccountInstance && !hasRedirectedToPendingValidationRef.current) {
                     clearReimbursementAccountDraft();
                     clearReimbursementAccount();
                 }
    @@ -228,6 +237,15 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
    
         const isDefaultReimbursementAccountData = deepEqual(reimbursementAccount, CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA);
         const hasLoadedData = reimbursementAccount?.achData && !isDefaultReimbursementAccountData && !reimbursementAccount?.isLoading;
    +    // For a pending USD account this page only redirects, so it must never paint the entry point. Derived during render
    +    // because effects run after paint. Not latched on the redirect ref: that flips mid-transition and the next render
    +    // would fall through to the entry point. policyID is matched because REIMBURSEMENT_ACCOUNT is persisted.
    +    const shouldRedirectToPendingValidation =
    +        policyCurrency === CONST.CURRENCY.USD &&
    +        achData?.state === CONST.BANK_ACCOUNT.STATE.PENDING &&
    +        !!hasLoadedData &&
    +        !isChangingBankAccount &&
    +        (!policyIDParam || achData?.policyID === policyIDParam);
         /**
          When this page is first opened, `reimbursementAccount` prop might not yet be fully loaded from Onyx.
          Calculating `shouldShowContinueSetupButton` immediately on initial render doesn't make sense as
    @@ -358,11 +376,13 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
                 return;
             }
    
    -        // If USD bank account is in pending state, we should navigate straight to the validation step and skip Continue step
    -        if (policyCurrency === CONST.CURRENCY.USD && achData?.state === CONST.BANK_ACCOUNT.STATE.PENDING) {
    -            setUSDBankAccountStep(CONST.BANK_ACCOUNT.STEP.VALIDATION);
    -            goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.VALIDATION);
    -            setShouldShowContinueSetupButton(shouldShowContinueSetupButtonValue);
    +        // Navigate straight to the validation step and skip the Continue step. Done from inside this page so that
    +        // openReimbursementAccountPage has already populated the achData that ConnectBankAccount reads.
    +        if (shouldRedirectToPendingValidation && !hasRedirectedToPendingValidationRef.current) {
    +            hasRedirectedToPendingValidationRef.current = true;
    +            // A push, not a forceReplace: replacing unmounts this page and its cleanup wipes REIMBURSEMENT_ACCOUNT,
    +            // leaving ConnectBankAccount with state 'SETUP' and a blank RHP.
    +            Navigation.navigate(ROUTES.BANK_ACCOUNT_USD_SETUP.getRoute({policyID: policyIDParam, page: CONST.BANK_ACCOUNT.PAGE_NAMES.VALIDATION, backTo}));
                 return;
             }
    
    @@ -378,7 +398,44 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
             // achData changes — not to local USDBankAccountStep updates — otherwise it races with prepareNextStep
             // and briefly pulls USDBankAccountStep back to the server value before the Onyx merge lands.
             // eslint-disable-next-line react-hooks/exhaustive-deps
    -    }, [policyIDParam, achData?.currentStep, shouldShowContinueSetupButtonValue, isNonUSDSetup, isPreviousPolicy, achData?.state, policyCurrency]);
    +    }, [
    +        policyIDParam,
    +        achData?.currentStep,
    +        shouldShowContinueSetupButtonValue,
    +        isNonUSDSetup,
    +        isPreviousPolicy,
    +        achData?.state,
    +        policyCurrency,
    +        hasLoadedData,
    +        isChangingBankAccount,
    +        shouldRedirectToPendingValidation,
    +        backTo,
    +    ]);
    +
    +    // Declared after the redirect effect so that on the commit where the redirect fires this runs with the blur flag
    +    // still unset and bails out, rather than racing the navigation it is meant to follow.
    +    useEffect(() => {
    +        if (!hasRedirectedToPendingValidationRef.current) {
    +            return;
    +        }
    +
    +        if (!isFocused) {
    +            hasBlurredAfterPendingRedirectRef.current = true;
    +            return;
    +        }
    +
    +        // The user navigated back onto this page, which the back handler cannot intercept for browser back. This page
    +        // only redirects for a pending account, so it would otherwise sit on the loader forever. Leave the flow.
    +        if (!hasBlurredAfterPendingRedirectRef.current || !shouldRedirectToPendingValidation) {
    +            return;
    +        }
    +
    +        if (backTo) {
    +            Navigation.goBack(backTo);
    +        } else {
    +            Navigation.dismissModal();
    +        }
    +    }, [isFocused, shouldRedirectToPendingValidation, backTo]);
    
         useEffect(() => {
             if (!prevPolicyCurrency || policyCurrency === prevPolicyCurrency) {
    @@ -648,6 +705,12 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy}: Reimbursemen
             );
         }
    
    +    // Keep the loader on screen for a pending USD account so the "Continue setup / Start over" entry point is never
    +    // painted on the way to the validation step.
    +    if (shouldRedirectToPendingValidation) {
    +        return <ReimbursementAccountLoadingIndicator onBackButtonPress={goBack} />;
    +    }
    +
         // Once fresh data has loaded, trust the live value to avoid a one-frame flash from the effect-synced state lagging achData.
         // On a "change bank account" instance never show "continue setup", since the shared data still describes the account being replaced.
         const shouldShowContinueSetupButtonToDisplay = !isChangingBankAccount && (hasLoadedData ? shouldShowContinueSetupButtonValue : shouldShowContinueSetupButton);
    diff --git a/src/pages/ReimbursementAccount/USD/USDVerifiedBankAccountFlowPage.tsx b/src/pages/ReimbursementAccount/USD/USDVerifiedBankAccountFlowPage.tsx
    --- a/src/pages/ReimbursementAccount/USD/USDVerifiedBankAccountFlowPage.tsx
    +++ b/src/pages/ReimbursementAccount/USD/USDVerifiedBankAccountFlowPage.tsx
    @@ -132,9 +132,14 @@ function USDVerifiedBankAccountFlowPage({route}: USDVerifiedBankAccountFlowPageP
    
         const onBackButtonPress = useCallback(() => {
             // When the bank account is pending validation it has already been submitted, so stepping back through the
    -        // setup pages doesn't make sense. Pop back to the entry point screen the user came from.
    +        // setup pages doesn't make sense. Leave the flow entirely rather than popping to ReimbursementAccountPage:
    +        // that page redirects a pending account straight back here, so returning to it would trap the user in a loop.
             if (currentEntry?.pageName === PAGE_NAMES.VALIDATION && reimbursementAccount?.achData?.state === CONST.BANK_ACCOUNT.STATE.PENDING) {
    -            Navigation.goBack(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute({policyID, backTo}));
    +            if (backTo) {
    +                Navigation.goBack(backTo);
    +            } else {
    +                Navigation.dismissModal();
    +            }
                 return;
             }
  10. MelvinBot commented on Sep 2, 2026

    @MelvinBot
    Contributor

    Accepted — all seven points and the smaller note are correct. I re-verified each one against 83cfe79 before rewriting, and I've corrected two line references in your list along the way. Three things in the working diff still need changing; the rest of it is what the updated proposal now specifies.

    What still needs changing in the diff

    1. (!policyIDParam || achData?.policyID === policyIDParam) is a pass-through, not a guard — and it becomes exploitable because of the cleanup skip.

    Two shipping entry points mount this page with no policyID:

    • WalletPage/index.tsx:243 — navigateToBankAccountRoute({bankAccountID, backTo}), no policyID, and nothing clears achData first.
    • CountrySelection.tsx:75 — neither param. It does call clearReimbursementAccount() at line 72 first, but that's an async Onyx.set.

    On both, !policyIDParam short-circuits the guard to true on first render. Combined with the cleanup skip (see point 3), a disk-persisted PENDING achData from a different policy satisfies it and fires the redirect at the wrong account — and BANK_ACCOUNT_USD_SETUP.getRoute silently drops an undefined policyID, so the validation page has nothing to correct itself with. Require the param instead:

    -        (!policyIDParam || achData?.policyID === policyIDParam);
    +        !!policyIDParam &&
    +        achData?.policyID === policyIDParam;

    The bug only reproduces from a workspace entry point, so scoping the redirect to those loses nothing.

    2. The new loader must not reuse goBack as its back handler.

    goBack switches on currentStep, and only the ValidationStep + PENDING case leaves the flow. If the server returns ACHContractStep alongside PENDING, back hits line 522, which is a bare goToWithdrawalAccountSetupStep(BENEFICIAL_OWNERS) — an Onyx.merge with no navigation. The user stays on the loader and their step is walked backwards. The CountryStep fallback at line 494 is the same dead end, reachable whenever achData.accountNumber is empty. Your diff removes the goToWithdrawalAccountSetupStep(VALIDATION) that used to force the step, so this is no longer self-correcting.

    Reuse the escape you already wrote:

    +    const leavePendingValidationFlow = () => (backTo ? Navigation.goBack(backTo) : Navigation.dismissModal());
    +
         if (shouldRedirectToPendingValidation) {
    -        return <ReimbursementAccountLoadingIndicator onBackButtonPress={goBack} />;
    +        return <ReimbursementAccountLoadingIndicator onBackButtonPress={leavePendingValidationFlow} />;
         }

    Use it in the escape effect and in USDVerifiedBankAccountFlowPage too, so there's one definition of "leave this flow" rather than three copies. Keep it a plain function, not a useCallback — this file compiles under React Compiler.

    3. Nothing else ever resets REIMBURSEMENT_ACCOUNT, so the cleanup skip is permanent.

    clearReimbursementAccount() has exactly three callers: the cleanup you're skipping, CountrySelection.tsx:72, and prepareNewBankAccountSetup — whose in-flow call site is VerifiedBankAccountFlowEntryPoint.tsx:134, the exact component your render guard stops rendering. Neither USDVerifiedBankAccountFlowPage nor ConnectBankAccount clears on unmount. openReimbursementAccountPage overwrites rather than resets, and its optimistic data only touches isLoading. The key is persisted, so a stale PENDING achData survives to disk until sign-out.

    That's acceptable — but it's the mechanism behind point 1, so tightening the guard isn't optional, and "stale achData outlives the flow" belongs in the acceptance criteria.

    Two corrections to your references

    And a confirmation that supports your framing: closeRHPFlow() and dismissModal() are equivalent for this screen pair. Both ReimbursementAccountPage and USDVerifiedBankAccountFlowPage are registered in SettingsModalStackNavigator, so the RHP navigator has a single child; closeRHPFlow finds routes.length === 1, targets the root, and pops the whole modal. Your dismissModal() does the same thing. Neither honours backTo, which is why the backTo-first ordering in your handler matters.


    Updated proposal follows.

    Proposal

    This is a regression of #93564. That issue was fixed by #94707 on 2026-07-10 and reverted five days later by #96182 because it caused deploy blocker #96130. It was never re-landed.

    What is the root cause of that problem?

    Unchanged from the original proposal, and independently re-verified at 83cfe79. The block at ReimbursementAccountPage.tsx:361-367 claims to skip the "Continue setup / Start over" screen for a pending USD account, but does not:

    1. setUSDBankAccountStep(VALIDATION) — USDBankAccountStep is write-only; no render path reads it.
    2. goToWithdrawalAccountSetupStep(VALIDATION) — navigation.ts:13-15 is an Onyx.merge of achData.currentStep, not a navigation.
    3. setShouldShowContinueSetupButton(...) sets the flag to true, because hasInProgressUSDVBBA returns true for every state other than OPEN and LOCKED, including PENDING.

    Execution falls through to line 653, which renders VerifiedBankAccountFlowEntryPoint with shouldShowContinueSetupButton = true — the screen the tester saw. The branch broke in #86645, which deleted the render branch consuming USDBankAccountStep and left the call site behind.

    Correction to the original proposal: statement 2 is not a no-op. It is a real Onyx.merge whose value is read by continueUSDVBBASetup's stepToPageName map, by the goBack switch, and by the route-sync effect at line 425. Removing it is a behaviour change: achData.currentStep will hold whatever the server returned instead of being forced to ValidationStep. That is what makes fix 2 above necessary.

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

    Two files. ikevin127's diff above, with the three amendments in fix 1-3.

    ReimbursementAccountPage.tsx

    1. Derive the condition during render, not in an effect. Effects run after paint, so an effect-only redirect still paints "Continue setup / Start over" for a frame — the issue's Actual Result, just faster. Add a plain derived const next to hasLoadedData: USD currency, achData.state === PENDING, hasLoadedData, not isChangingBankAccount, and !!policyIDParam && achData?.policyID === policyIDParam. Not useMemo — this file compiles under React Compiler.
    2. Short-circuit the render with it, returning ReimbursementAccountLoadingIndicator instead of VerifiedBankAccountFlowEntryPoint, placed after the existing loader at line 569. Give it the leave-the-flow handler, not goBack.
    3. Redirect with a push, replacing the three statements at 361-367 with Navigation.navigate(ROUTES.BANK_ACCOUNT_USD_SETUP.getRoute({policyID: policyIDParam, page: CONST.BANK_ACCOUNT.PAGE_NAMES.VALIDATION, backTo})). PAGE_NAMES.VALIDATION ('validation'), not STEP.VALIDATION ('ValidationStep') — an unmatched page name falls through findIndex to index 0, the Country page. Forward backTo.
    4. Not forceReplace. linkTo/index.ts:197-198 turns it into REPLACE, which unmounts this page and runs the cleanup that wipes the data the destination needs. See below.
    5. Skip the unmount wipe when the instance is unmounting because it redirected. The cleanup at lines 184-194 calls clearReimbursementAccount(), which Onyx.sets the key to DEFAULT_DATA (achData: {state: 'SETUP'}). ConnectBankAccount branches purely on achData.state and fetches nothing, so SETUP matches no branch and it renders a header-only RHP titled "Add bank account" — [$250] Wallet - Blank RHP is shown after adding a Bank Account #96130 exactly. This bites on cold load even with a push.
    6. Two refs, not one. The redirect latch flips synchronously while the page is still focused, so it can't distinguish "redirect in flight" from "user came back". Add a second ref recording an actual blur, plus an escape effect declared after the redirect effect so it doesn't race the navigation it follows. Without it, browser back leaves the page on the loader forever, since the back handler can't intercept it.

    USDVerifiedBankAccountFlowPage.tsx

    1. The VALIDATION + PENDING back handler must leave the flow. Lines 133-139 currently go back to BANK_ACCOUNT_WITH_STEP_TO_OPEN, which resolves to SCREENS.REIMBURSEMENT_ACCOUNT → ReimbursementAccountPage, which now redirects straight back. Use backTo with a Navigation.dismissModal() fallback; Navigation.goBack(undefined) would pop onto the redirector.
    Why the existing stepToOpen mechanism doesn't solve this

    getStepToOpenFromRouteParams does map VALIDATE: 'validate' → CONST.BANK_ACCOUNT.STEP.VALIDATION, and ConnectExistingBusinessBankAccountPage.tsx:70 is the idiomatic way to pass it via appendParam.

    It doesn't help here. ReimbursementAccountPage still consumes stepToOpen at lines 260, 344 and 424 — it isn't dead — but only to seed currentStep state, reset the sub-step, and sync the route. Since #86645 it selects no rendered step component; the only thing the page renders on this path is VerifiedBankAccountFlowEntryPoint. A navigation to the USD flow route is still required.

    Acceptance criteria

    Verified by ikevin127 locally against a pending USD account on web:

    • Entry from Workflows opens the validation step with no interstitial "Continue setup / Start over" frame.
    • In-app back and browser back both return to Workflows.
    • Cold load (refresh, then re-enter from Workflows) does not blank the RHP.
    • VERIFYING, OPEN, fresh setup, non-USD and change-bank-account are unaffected. Typechecks clean.

    Still to verify:

    • The micro-deposit submit round trip. ValidateBankAccountWithTransactions needs a genuinely pending account; a forced client state 404s. The diff doesn't touch BankAccountValidationForm or validateBankAccount and the bankAccountID sent is unchanged, but this should be exercised for real.
    • Settings → Wallet → tap an existing bank account (WalletPage/index.tsx:243, no policyID) while a PENDING achData for a different policy is on disk. Must not redirect. This is what fix 1 guards.
    • Back on the loading indicator while achData.currentStep is ACHContractStep rather than ValidationStep. Must leave the flow, not merge the step backwards. This is what fix 2 guards.
    • Stale achData outliving the flow, since the cleanup skip means nothing resets REIMBURSEMENT_ACCOUNT until sign-out.

    What alternative solutions did you explore? (Optional)

    Related issues


    💡 Suggested AI code review rule

    Unchanged from the original proposal: CONSISTENCY-19 — flag useState whose getter is never read by a render path or by any logic other than a guard around its own setter, especially when a PR deletes a render branch and leaves the setX(...) calls behind. This bug is that pattern, and it shipped twice.


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


    view run

  11. ikevin127 commented on Sep 2, 2026

    @ikevin127
    Contributor

    @MelvinBot implement this to create a draft PR.

  12. MelvinBot commented on Sep 2, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: #100113

    Please mark it as "Ready for review" when it is ready for review.

    It implements your working diff plus the three amendments from the approved proposal. Two files, +85/−9.

    What landed

    • ReimbursementAccountPage.tsx — render-derived shouldRedirectToPendingValidation, a push (not forceReplace) to BANK_ACCOUNT_USD_SETUP at PAGE_NAMES.VALIDATION with backTo forwarded, the render short-circuit to ReimbursementAccountLoadingIndicator, the unmount-cleanup skip, and the two-ref latch with the escape effect declared after the redirect effect.
    • USDVerifiedBankAccountFlowPage.tsx — the VALIDATION + PENDING back press now leaves the flow via backTo with a Navigation.dismissModal() fallback, instead of returning to the page that redirects back into it.

    The three amendments

    1. The policy guard is !!policyIDParam && achData?.policyID === policyIDParam rather than (!policyIDParam || ...), so the WalletPage and BankAccountPurposePage entry points that pass no policyID can't satisfy it with another policy's persisted account.
    2. The loader's back button gets a shared leavePendingValidationFlow handler, not goBack — goBack switches on currentStep and several cases only Onyx.merge with no navigation, which would strand the user on the loader.
    3. That handler is the single definition of "leave this flow", reused by the escape effect.

    One deviation from the proposal text, and the reason for it: I wrote leavePendingValidationFlow as a useCallback rather than a plain function. The compliance check shows ReimbursementAccountPage.tsx does not compile under React Compiler — it fails on both Babel and OXC with 3 × "Cannot access refs during render" on origin/main, before any of my changes. Since the file isn't compiled, the no-manual-memoization rule doesn't apply to it and the surrounding useCallback idiom does. It also lets the escape effect list a real dependency instead of a lint suppression.

    Checks

    typecheck, lint-changed, spell-changed and the storybook smoke test all pass. 18 bank-account and reimbursement suites pass (249 tests). The React Compiler check is byte-identical to the origin/main baseline — same 3 pre-existing errors, only the line number shifts as the existing code moved down — so no regression and no new memoization divergence; USDVerifiedBankAccountFlowPage.tsx passes both compilers before and after.

    Two things I did not do, stated plainly rather than left implied. The full Jest suite exceeded the local time budget, so CI is the first place it runs end to end; --findRelatedTests reports no test file covers either changed file directly, so the 18 suites above are the existing coverage. And I ran no manual verification — the PR carries no screenshots, and the Tests, Offline tests and QA Steps sections are left as TODOs for you, seeded with the suggested steps from the proposal's acceptance criteria. The micro-deposit submit against a genuinely pending account is the one that still needs a real backend round trip.

    I added no unit tests. The change is navigation and render-gating in a screen with no existing test harness, so a meaningful test would mean building that harness — worth doing, but a larger change than this fix, and your call whether to fold it in.


    view run

  13. 12 remaining items

  14. added
    Weekly
    Daily
    Awaiting Payment
    and removed
    Weekly
    on Sep 10, 2026
  15. melvin-bot commented on Sep 16, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  16. melvin-bot commented on Sep 16, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  17. ikevin127 commented on Sep 19, 2026

    @ikevin127
    Contributor

    @mallenexpensify May I please have a payment summary on this one ? BZ Checklist completed above 🙌

  18. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    @mallenexpensify Huh... This is 4 days overdue. Who can take care of this?

  19. mallenexpensify commented on Sep 22, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @ikevin127 due $250 via NewDot

  20. quinthar commented on Sep 27, 2026

    @quinthar
    Contributor

    Approved $250 to @ikevin127

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternalInternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions