Skip to content

Skip the Continue setup step for a pending USD bank account - #100113

Merged
luacmartins merged 10 commits into
mainfrom
claude-pendingUsdBankAccountSkipsContinueSetup
Sep 9, 2026
Merged

luacmartins merged 10 commits into
mainfrom
claude-pendingUsdBankAccountSkipsContinueSetup

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

A USD bank account left in the PENDING state is supposed to open the "Validate your bank account" step directly. Instead it shows the "Continue setup / Start over" screen, because the branch that was meant to skip that screen has been dead code since #86645 removed the render path it depended on.

The branch set three pieces of state, none of which navigate:

  • setUSDBankAccountStep(VALIDATION) — USDBankAccountStep is write-only; no render path reads it.
  • goToWithdrawalAccountSetupStep(VALIDATION) — despite the name, an Onyx.merge of achData.currentStep.
  • setShouldShowContinueSetupButton(...) — sets the flag to true, since hasInProgressUSDVBBA returns true for every state that is not OPEN or LOCKED, PENDING included.

Execution then fell through to the terminal render and painted VerifiedBankAccountFlowEntryPoint with the Continue setup button showing. This is a regression of #93564, whose fix (#94707) was reverted by #96182 because it caused deploy blocker #96130 ("blank RHP after adding a bank account").

What this PR does

ReimbursementAccountPage now redirects a pending USD account to the validation page itself, rather than the caller doing it. That ordering is the point: openReimbursementAccountPage is only called from this page, and ConnectBankAccount does no fetching of its own — it branches purely on achData.state. Redirecting from here means the data is already populated when the destination mounts, which is what #94707 got wrong.

Four details make the difference between this and the reverted attempt:

  1. The condition is derived during render, not in an effect. Effects run after paint, so an effect-only redirect still paints the Continue setup screen for a frame — the issue's Actual Result, just faster. The same derived value short-circuits the render to ReimbursementAccountLoadingIndicator.
  2. It is a push, not a forceReplace. forceReplace sets the action to REPLACE, which unmounts this page; its cleanup then Onyx.sets REIMBURSEMENT_ACCOUNT to DEFAULT_DATA (achData: {state: 'SETUP'}), which matches none of ConnectBankAccount's branches and renders the blank header-only RHP of [$250] Wallet - Blank RHP is shown after adding a Bank Account #96130.
  3. The unmount cleanup skips the wipe when the page unmounts only because it redirected. Even with a push, on a cold load this page can unmount after the redirect has dispatched, wiping the data out from under ConnectBankAccount — same blank RHP, different trigger.
  4. USDVerifiedBankAccountFlowPage's pending back press now leaves the flow. It previously went back to BANK_ACCOUNT_WITH_STEP_TO_OPEN, which resolves to ReimbursementAccountPage — the page that now redirects straight back here. It uses backTo, falling back to Navigation.dismissModal(), since Navigation.goBack(undefined) would pop back onto the redirector.

Two guards keep the redirect from firing on the wrong account:

  • policyID must match. REIMBURSEMENT_ACCOUNT is persisted to disk, so on a cold load achData can still describe a different policy's account. Entry points that pass no policyID at all (WalletPage passes only a bankAccountID; BankAccountPurposePage passes neither) are excluded outright, since there is nothing to match them against. This matters more than usual because of change 3 — skipping the cleanup keeps that stale data around longer.
  • Two refs, not one. A single latch cannot distinguish "the redirect is in flight and we are still on top" from "the user has navigated back onto us", because it flips while the page is still focused. A second ref records an actual blur, and its effect is declared after the redirect effect so it does not race the navigation it follows. Without this, browser back (which the back handler cannot intercept) leaves the page on the loader forever.

The loader's back button deliberately does not reuse goBack: that callback switches on achData.currentStep, and several of its cases only perform an Onyx.merge with no navigation at all, which would strand the user on the loading indicator.

Behaviour change worth flagging for review: removing goToWithdrawalAccountSetupStep(VALIDATION) also removes a real Onyx.merge of achData.currentStep. That value is read by the stepToPageName map in continueUSDVBBASetup, by the goBack switch, and by the route-sync effect. currentStep will now hold whatever the server returned instead of being forced to ValidationStep.

Fixed Issues

$ #99998
PROPOSAL: #99998 (comment)

AI Tests

Automated checks Melvin ran locally against these changes:

Check Result
npm run typecheck ✅ passed
npm run lint-changed ✅ passed
npm run spell-changed ✅ passed (2 files, 0 issues)
npm run storybook -- --smoke-test --ci ✅ passed
npm test — 18 bank-account/reimbursement suites ✅ passed (249 tests)
npm run react-compiler-compliance-check ⚠️ unchanged from baseline — see below
npm test (full suite) ⚠️ not run to completion locally — see below
  • React Compiler: ReimbursementAccountPage.tsx fails both the Babel and OXC checks with 3 × "Cannot access refs during render" on origin/main before this PR, and with the identical 3 errors after it (only the line number shifts, as the pre-existing code moved down). No regression, and no new memoization divergence. Because that file does not compile, its existing useCallback idiom still applies, which is why the new handler is memoized to match the surrounding code. USDVerifiedBankAccountFlowPage.tsx passes both compilers before and after.
  • Full Jest suite: exceeded the local time budget available to Melvin. --findRelatedTests reports no test file covers either changed file directly, so the 18 suites above are the relevant existing coverage. CI runs the full suite.

Unit tests were added after review feedback that the new logic was untested: tests/unit/pages/ReimbursementAccountPagePendingRedirectTest.tsx (18 tests) and tests/unit/pages/USDVerifiedBankAccountFlowPageBackTest.tsx (4 tests). Both suites were also run against origin/main: the 9 tests asserting new behaviour fail there and pass here, and each conjunct of shouldRedirectToPendingValidation was mutation-checked so no guard is asserted vacuously.

Tests

  1. Sign in to NewDot with an Expensifail account.
  2. Create a workspace.
  3. Go to Workspace settings > Workflows > Add bank account.
  4. Start adding a bank account via the "Connect manually" option and complete the steps.
  5. On the final step click "Continue" and verify the "Validate your bank account" page is displayed.
  6. Navigate back to Workflows and click the pending bank account.
  7. Verify the "Validate your bank account" RHP opens instantly, and that the "Continue setup" / "Start over" screen never appears — not even for a single frame.
  8. Press the back button in the RHP header and verify you land back on Workflows — not on the validate step again, and not on a stuck loading spinner.
  9. On web, repeat step 6 and then use the browser back button. Verify you land back on Workflows and the page is not left on a loading indicator.
  10. Reload the app on the Workflows page, then click the pending bank account. Verify the RHP shows "Validate your bank account" and is not blank (this is the regression that reverted Open validation RHP directly for pending USD bank accounts #94707).
  11. Enter the micro-deposit amounts for the pending account and submit. Verify validation succeeds and the account moves out of the pending state.
  12. Go to Settings > Wallet and tap an existing personal bank account while a pending workspace bank account is still in Onyx. Verify you are not redirected into the validate step.
  13. Regression check — verify these flows are unchanged: a bank account in VERIFYING state, an OPEN account, starting a fresh bank account setup, a non-USD (e.g. AUD) bank account, and the "change bank account" flow.
  • Verify that no errors appear in the JS console

Offline tests

Workflows cannot be used for this: the row is offline-disabled three ways (WorkflowsPaymentsTab.tsx:202 passes no onPress, :212 sets disabled: isOffline, and the "Confirm" action at :277 is isActionDisabled, which Button/index.tsx:497 honours). Settings > Wallet has no offline gate at all (PaymentMethodList.tsx:624 disables only the pending-delete case), so it is the reachable offline entry point.

  1. Online, open Workspace settings > Workflows and click the pending USD bank account once so REIMBURSEMENT_ACCOUNT is cached. Go back.
  2. Turn off your network connection.
  3. Open Settings > Wallet and click the pending bank account, or its "Confirm test transactions" action.
  4. Verify the "Validate your bank account" RHP opens from cached data. The "Continue setup / Start over" screen must not appear, and the RHP must not be blank.
  5. Verify the submit button is replaced by the offline message and the micro-deposit amounts cannot be submitted. This comes from FormProvider defaulting enabledWhenOffline = false, which BankAccountValidationForm does not override.
  6. Press back and verify you return to Settings > Wallet rather than being stuck on the loading indicator.
  7. Reconnect and verify the amounts form becomes submittable.

QA Steps

Same as tests, run against staging. Steps 1–13 in the Tests section above require no dev-only setup — use an Expensifail account and a manually connected test bank account.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Redirect straight to the validation step from ReimbursementAccountPage once
achData has loaded, deriving the condition during render so the entry point is
never painted. Skip the unmount wipe of REIMBURSEMENT_ACCOUNT when the page
unmounts only because it redirected, so ConnectBankAccount still has the data it
reads. Make the USD flow page's pending back press leave the flow instead of
returning to the page that redirects back into it.

Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Fixed and pushed — the only real failure was Oxfmt check. The useEffect dependency array in src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx:414 was written one-item-per-line; oxfmt wants it on a single line. Ran npm run fmt and committed the result — whitespace only, no behaviour change.

Check independent approval is also red, but that one just needs a human review and isn't something I can fix.

Details

CI log:

src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
Error: Oxfmt diff detected! Please run `npm run fmt` and commit the changes.

The diff:

-    }, [
-        policyIDParam,
-        achData?.currentStep,
-        ...
-    ]);
+    }, [policyIDParam, achData?.currentStep, shouldShowContinueSetupButtonValue, ...]);

Local verification after the fix:

Check Result
npm run fmt (clean tree after) ✅ passed
npm run typecheck ✅ passed
npx eslint on the changed file ✅ 0 errors (9 pre-existing seatbelt-allowed warnings)

No browser testing was run: the change is formatting only, so there is nothing to verify at runtime.


view run

@ikevin127

This comment has been minimized.

@MelvinBot

MelvinBot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

I could only verify one of the seven checks. Steps 1–5 all need a USD bank account in the PENDING state, and this fresh test account has none — creating one via Workflows → Payments → Add bank account → Connect manually stops at the "Validate your account" email security code screen, which I can't clear because I have no mailbox access. I did confirm the no-bank-account path is unaffected.

Validate your account email OTP screen blocking bank account creation

Step Status
1. Pending USD bank account in Workflows opens "Validate your bank account" directly, with no Continue setup / Start over frameNot reachable. No pending USD bank account exists for this account, and creating one is gated behind an email security code (ResendValidateCode) that I cannot retrieve. I did not attempt to guess it.
Validate your account email OTP screen blocking bank account creation
❌
2. In-app back and browser back return to Workflows, no loop and no stuck loaderNot reachable — same pending-account precondition as step 1.
❌
3. Refresh on another tab, re-enter from Workflows, RHP is not blankNot reachable — same pending-account precondition as step 1.
❌
4. Submitting micro-deposit amounts triggers ValidateBankAccountWithTransactionsNot reachable — no pending account to validate.
❌
5. Settings > Wallet bank account does not redirect while another policy has a pending account in OnyxNot reachable — this account has no bank accounts at all.
❌
6. A workspace with no bank account still opens the normal setup flowCreated a new USD workspace, then Workspace settings → Workflows → Payments → Add bank account. It opened the standard "Streamline payments" screen with "Log into your bank" and "Connect manually", not a validation redirect.
Fresh workspace Add bank account shows normal Log into your bank / Connect manually entry screen
✅
7. No new JS console errorsNo 4xx or 5xx responses in the network log across workspace creation and the bank-account entry flow. The web driver exposes no console capture, so this is network traffic only, not a direct console read.
✅

To get steps 1–5 covered, the account needs a bank account already in PENDING state, or a way to receive the validation code.


view run · no recording available

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The remaining failure is unrelated to this PR — it's a date-dependent test that only breaks when CI runs on the 2nd of the month. Today is 2026-09-02. Nothing to push here.

The earlier Oxfmt check failure is fixed and green (commit c74288c).

Failing test: tests/unit/NextStepUtilsTest.ts › monthly on the 2nd — expected 2026-10-02, got 2026-09-02.

Two implementations of "next Nth of the month" disagree on the boundary day, and today is that day:

  • Production: src/libs/NextStepUtils.ts:212-214 uses setDate(new Date(), 2) then bumps a month only if (isPast(...)). With today already the 2nd, that instant is not in the past, so it stays on this month.
  • Test expectation: src/libs/DateUtils.ts:1291-1292 uses if (day < nth), which is false when day === nth, so it rolls to next month.

On any other day of the month the two agree and the test passes.

Why it isn't this PR, and where the divergence came from

This PR touches only:

  • src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
  • src/pages/ReimbursementAccount/USD/USDVerifiedBankAccountFlowPage.tsx

Neither is imported by NextStepUtils, DateUtils, or the failing test. The other 7 Jest shards passed; only shard 3 failed, on this one assertion.

The two code paths were last changed together by the monthlyNextStepDateOffByOne work that landed around 2026-08-14 (#97875, "Monthly submission date in Next Step differs by one day from date set in Workflows"). NextStepUtils kept the isPast check while the test switched to DateUtils.getNextNthOfMonth, which uses strict <. That left the equal-day case inconsistent.

Per repo convention I'm not fixing an unrelated failure inside this PR. Reply with @MelvinBot file an issue for this if you want it tracked separately, or just re-run the shard tomorrow and it will pass.

Check independent approval is also red, but that one just needs a human review.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The remaining failure is not from this PR. Oxfmt check is green after my last push. What's red now is test (job 3) → tests/unit/NextStepUtilsTest.ts → "monthly on the 2nd", which fails on main too — it only breaks when the calendar date happens to be the 2nd, and today is 2026-09-02. Nothing to push here.

I did not fix it, since it's outside this PR's scope (this PR touches only ReimbursementAccountPage.tsx and USDVerifiedBankAccountFlowPage.tsx). Re-running the job on any other day will pass. Worth a separate flaky-test issue — I didn't find an existing one.

Evidence and root cause

Reproduced on main. I checked out main at 2aeff10 (none of this PR's commits) and ran the suite:

✕ monthly on the 2nd
    -     "dateTime": "2026-10-02",   <- expected
    +     "dateTime": "2026-09-02",   <- received
Tests: 1 failed, 45 passed

Byte-identical to the CI failure on this branch.

Why it only fails on the 2nd. The test and the production code compute the "next 2nd of the month" two different ways, and they only disagree when today is the 2nd:

Every other day of the month the two agree, which is why this passes 30 days out of 31.

Fixing it means picking which semantic is correct for "today is the submit day" and making both sides use it — a behaviour decision about scheduled submit, not a formatting or navigation change, so it belongs in its own PR.


view run

Cover every branch the change introduces, and pin the behaviour it must not
alter. Both suites were checked against origin/main: the 9 tests asserting new
behaviour fail there and pass here, and each conjunct of
shouldRedirectToPendingValidation was mutation-checked so the guards are not
asserted vacuously.

ReimbursementAccountPagePendingRedirectTest covers the redirect itself (route,
backTo, fires once, entry point never painted), the skipped unmount wipe, the
loader's back button, the blur-then-refocus exit, and the six states that must
not redirect.

USDVerifiedBankAccountFlowPageBackTest covers the pending validation back press
leaving the flow, and the step-by-step back behaviour it must not disturb.

Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
@MelvinBot

MelvinBot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Added tests for every branch the change introduces, plus guards for the behaviour it must not alter. Pushed as 6355954.

These are not vacuous. I ran both suites against origin/main: 9 of the 22 fail there and pass on this branch. The other 13 are the regression guards, which pass on both by design. I also mutated shouldRedirectToPendingValidation down to currency === USD && state === PENDING and confirmed each dropped conjunct breaks a specific test.

New logic Covered by
Redirect pushes the validation route, entry point never painted redirects to the validation step instead of painting the Continue setup entry point
backTo carried into the redirect route carries backTo through to the validation route
hasRedirectedToPendingValidationRef latch redirects only once even when Onyx pushes another update for the same account
Unmount cleanup skipped after redirecting (the blank-RHP regression) keeps the account data in Onyx when it unmounts because it redirected
Loader back button → goBack(backTo) / dismissModal() returns to backTo when one was passed, dismisses the modal when there is no backTo
Two-ref blur/refocus exit leaves the flow when the user navigates back onto it, does not leave the flow while the redirect is still in flight
USDVerifiedBankAccountFlowPage pending back press leaves the flow to backTo instead of returning to the page that redirects back here, dismisses the modal when there is no backTo

Unchanged behaviour pinned: OPEN, VERIFYING, SETUP and LOCKED accounts; non-USD workspaces; isChangingBankAccount; a pending account belonging to a different policy; entry points passing no policyID (Wallet); data still loading; the unmount wipe still running when no redirect happened; and the flow page's step-by-step back navigation.

Each "must not redirect" case asserts both that no validation route was pushed and that the entry point still rendered — without the second assertion, dropping the policyID guards left the page parked on the loader and the tests still passed.

Checks run
Check Result
npm run typecheck ✅ passed
eslint on both new files ✅ passed
npm run fmt (oxfmt) ✅ no changes
cspell on both new files ✅ no issues
npm test — 20 bank-account/reimbursement suites ✅ 271 tests passed
Both new suites vs origin/main ✅ 9 failed as expected

npm run lint-changed and npm run spell-changed could not run in this environment — both call git merge-base against origin/main, which fails on this shallow checkout. I ran eslint and cspell directly on the two files instead. The full Jest suite exceeded the local time budget; CI runs it.

The description said "No unit tests are added here" — I have updated that line so it no longer contradicts the branch.


view run · view recording

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The Oxfmt failure is fixed (pushed in c74288c). The remaining test (job 3) failure is unrelated to this PR — tests/unit/NextStepUtilsTest.ts › monthly on the 2nd is a calendar-dependent flake that can only fail on the 2nd of the month, which is today.

Nothing else to push here. Check independent approval just needs a human reviewer.

Why the test failure is unrelated

This PR touches only ReimbursementAccountPage.tsx, USDVerifiedBankAccountFlowPage.tsx, and two new test files under tests/unit/pages/. It does not touch NextStepUtilsTest.ts, NextStepUtils.ts, or DateUtils.ts.

I reproduced the failure locally on this branch: the suite passed on the first run and failed on the second with no code change in between.

Root cause — a same-millisecond race. The two sides of the assertion compute the expected date differently:

  • The test builds its expectation from DateUtils.getNextNthOfMonth(2), which compares whole days: on the 2nd, day < nth is false, so it always returns Oct 2.
  • The implementation at src/libs/NextStepUtils.ts:212-217 builds setDate(new Date(), 2) — today's date at the current time of day — and rolls forward a month only if isPast(...). date-fns implements that as +date < Date.now() (strict <). When the new Date() and the Date.now() inside isPast land in the same millisecond, it returns false, so no roll-forward and the result stays Sep 2.

Hence the CI diff:

-     "dateTime": "2026-10-02",
+     "dateTime": "2026-09-02",

On any other day of the month the two paths agree regardless of timing, which is why this has not been noticed before.

Suggested fix (out of scope for this PR): make the comparison day-granular rather than instant-granular — for example compare startOfDay(etaDateTime) against startOfDay(new Date()), or have NextStepUtils reuse DateUtils.getNextNthOfMonth.

The Oxfmt fix

The useEffect dependency array in src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx:414 was one item per line; oxfmt wants it on a single line. Ran npm run fmt and committed the result — whitespace only.

Check Result
Oxfmt check (CI, after push) ✅ passed
npm run typecheck ✅ passed
npx eslint on the changed file ✅ 0 errors

view run

@ikevin127

This comment has been minimized.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Not related to this PR — it's a calendar-dependent test that breaks on the 2nd of every month. Today is 2026-09-02.

The test and the code compute "next 2nd of the month" with two different implementations that only disagree when today's day-of-month equals autoReportingOffset:

This PR changes four files, none of them NextStepUtils.ts, DateUtils.ts, or NextStepUtilsTest.ts, so main fails the same way today. The mismatch was introduced when #97202 switched the expectation to getNextNthOfMonth on 2026-07-28.

Why it hasn't been caught before, and how to fix it

It only fires on one day a month, so most CI runs miss it. The other monthly cases in the suite assert an etaKey rather than a dateTime, so they're immune.

Worth noting the code path is also unstable on that day even by itself: setDate(new Date(), 2) captures one clock read and isPast takes another. If they land in different milliseconds the result flips to 2026-10-02, which is why this can look intermittent rather than consistently red.

The real fix is to make the two agree — have NextStepUtils call DateUtils.getNextNthOfMonth(policy.autoReportingOffset) instead of hand-rolling setDate/isPast, which also settles the "is today included" question in one place. Failing that, the test should freeze the clock with jest.useFakeTimers().setSystemTime(...) so it can't depend on the run date. Either belongs in its own PR, not this one.

I could not run the suite locally to confirm — the jest command was blocked by the sandbox in this run — so the above is from reading the two implementations against today's date.


view run

Comment on lines +95 to +104
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
({
policyID: POLICY_ID,
state: CONST.BANK_ACCOUNT.STATE.PENDING,
currentStep: CONST.BANK_ACCOUNT.STEP.VALIDATION,
bankAccountID: 1234,
currency: CONST.CURRENCY.USD,
country: CONST.COUNTRY.US,
...overrides,
}) as ACHDataReimbursementAccount;

@ikevin127 ikevin127 Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 The new fixtures hand-roll type assertions instead of using the repo's createMock helper. Four occurrences, each with an eslint suppression:

// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
}) as ACHDataReimbursementAccount;

// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const navigation = {} as PageProps['navigation'];

tests/utils/createMock.ts exists for exactly this, is used across 314 test files, and its docstring is explicit: "The single unavoidable assertion to the full type is isolated here, instead of being repeated as as SomeType at every mock in every test." More pointedly, tests/unit/ReimbursementAccountUtilsTest.ts already mocks this exact type with zero casts:

getBankAccountIDAsNumber(createMock<ACHDataReimbursementAccount>({bankAccountID: 42}))

Suggested fix:

-const buildAchData = (overrides: Partial<ACHDataReimbursementAccount> = {}) =>
-    // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
-    ({
+const buildAchData = (overrides: PartialDeep<ACHDataReimbursementAccount> = {}) =>
+    createMock<ACHDataReimbursementAccount>({
         policyID: POLICY_ID,
         state: CONST.BANK_ACCOUNT.STATE.PENDING,
         ...overrides,
-    }) as ACHDataReimbursementAccount;
+    });

Why this matters concretely: ACHDataReimbursementAccount is not all-optional. It requires corpay (from ACHData) and ACHRequestReportActionID, which is why the cast was needed at all. A bare as silences the checker completely, so if a field these tests branch on is renamed (say state to bankAccountState), the fixture keeps compiling, the object no longer matches what the app produces, and every "must not redirect" test passes vacuously against a shape production never emits. createMock takes PartialDeep<T>, so the partial is still type-checked at the call site and a rename fails the build instead of silently gutting the suite.

🟡 The two test files duplicate their setup. buildAchData, PENDING_ACCOUNT, POLICY_ID, BACK_TO and the entire Navigation mock block are copy-pasted. Given both suites exist to test two halves of one behaviour, extract the shared fixture and mock into tests/utils/. Otherwise the next person changing the ACH shape has to find and fix both.

🟡 Coverage gap: policyCurrency resolved from achData rather than the policy. Every test seeds a policy, so policyCurrency always comes from policy.outputCurrency. When no policy is loaded it falls back to achData?.currency ?? reimbursementAccountDraft?.currency. That path is untested and it is not academic: getBankAccountConnectionStatus treats an absent currency as USD (its guard is !!currency && currency !== USD), so the Workflows row can render "Please confirm test transactions" with a Confirm button while shouldRedirectToPendingValidation evaluates false and the user lands on the interstitial anyway. That is the exact bug this PR fixes, surviving in a narrow case. Add a test with policy = null and achData.currency = USD.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three addressed and pushed as 4026c6a.

1. createMock instead of hand-rolled assertions. All four as casts and their eslint suppressions are gone — buildAchData now returns createMock<ACHDataReimbursementAccount>(...) taking PartialDeep, and both navigation doubles are createMock<PageProps['navigation']>({}). One more appeared while doing point 3: Policy declares outputCurrency as required, so the no-currency policy fixture uses createMock too rather than a cast.

2. Shared setup extracted to tests/utils/ReimbursementAccountTestUtils.ts — buildAchData, PENDING_ACCOUNT, POLICY_ID, OTHER_POLICY_ID, BACK_TO, and the Navigation double as createNavigationMock(). jest.mock factories are hoisted above imports, so each suite calls that factory from inside its own jest.mock via jest.requireActual rather than importing it at the top — same shape as tests/navigation/getStateForDynamicRouteTests.ts:7.

3. policyCurrency fallback now covered — 4 tests, suite is 22 → 26 total across both files. Two things I found while writing them are worth your call:

  • The fallback only applies while policy is falsy (policy ? policy.outputCurrency : ...), and in that state the page returns the FullPageNotFoundView at ReimbursementAccountPage.tsx:635 — never the entry point. So expectNoPendingRedirect can't be used there; those two tests assert the navigation the fallback produced instead, and say so in a comment. They are not vacuous: I replaced the expression with policy?.outputCurrency and both fail.
  • The narrow surviving case is a policy that loaded without an outputCurrency, not a null policy — with policy truthy the fallback is skipped entirely, so policyCurrency is undefined and shouldRedirectToPendingValidation is false while getBankAccountConnectionStatus still reads absent as USD. That is now pinned by does not redirect when no currency can be resolved at all, which documents current behaviour rather than asserting the ideal. I deliberately did not change production code for it. Aligning would mean treating an absent currency as USD, matching isNonUSDWorkspace on line 151 of the same file — a one-line change, but it widens the redirect condition in exactly the area that produced the earlier revert, so it should be your decision, not a drive-by. Say the word and I'll make it plus a test that flips.

npm run typecheck, eslint on the three files, cspell, and oxfmt all pass; both suites are green after merging main (which had moved on).


view run

@ikevin127

This comment has been minimized.

MelvinBot and others added 3 commits September 3, 2026 02:23
Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
Replace the four hand-rolled `as` assertions in the two new suites with the
repo's createMock helper, so the fixtures stay type-checked against the real
ACH and navigation-prop shapes instead of silently drifting from them.

Move the shared setup (buildAchData, PENDING_ACCOUNT, POLICY_ID, BACK_TO and
the Navigation double) into tests/utils/ReimbursementAccountTestUtils.ts so
both halves of the behaviour are described in one place.

Cover the policyCurrency fallback that reads from achData and the draft when
no policy is loaded: two tests for the legs that do redirect, one for a
non-USD fallback, and one pinning that an absent currency does not redirect.

Co-authored-by: ikevin127 <ikevin127@users.noreply.github.com>
Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
…://192.168.127.1:1037/github.com/Expensify/App into claude-pendingUsdBankAccountSkipsContinueSetup

Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Claude's API is currently overloaded (HTTP 529). This is a temporary issue on Anthropic's side. Try again in a few minutes, or check status.anthropic.com.

Run details

Comment on lines +32 to +34
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const actualNav = jest.requireActual('@react-navigation/native');
// eslint-disable-next-line @typescript-eslint/no-unsafe-return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Minor, non-blocking. The @react-navigation/native mock still carries two suppressions:

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const actualNav = jest.requireActual('@react-navigation/native');
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return {...actualNav, ...};

and ones at tests/unit/pages/USDVerifiedBankAccountFlowPageBackTest.tsx lines 28/30.

The repo's usual shape for this types the result instead of suppressing, e.g. tests/ui/WorkspaceMembersSelectionListTest.tsx:38:

const actualNavigation: typeof ReactNavigation = jest.requireActual('@react-navigation/native');

Worth aligning, since it removes the last four suppressions in these files and you already use the typed form two lines away for jest.requireActual<typeof ReimbursementAccountTestUtils>. Both patterns exist in the codebase, so this is preference rather than a violation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — pushed as 5b3b933.

Both mocks now use jest.requireActual<typeof ReactNavigation>('@react-navigation/native') with a import type * as ReactNavigation from '@react-navigation/native' at the top, so the two no-unsafe-assignment / no-unsafe-return suppressions are gone from each file:

That was the last suppression in either file — grep eslint-disable across both suites and the shared util now returns nothing.

npm run typecheck, eslint, and oxfmt pass; both suites still green (22 and 4).


view run

@ikevin127

This comment has been minimized.

The @react-navigation/native mock in both suites suppressed no-unsafe-assignment
and no-unsafe-return around an untyped jest.requireActual. Typing the call with
`<typeof ReactNavigation>` removes the last four suppressions in these files and
matches the form already used two lines away for the test-utils factory.

Co-authored-by: ikevin127 <ikevin127@users.noreply.github.com>
Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ MelvinBot CI Fix Loop Detected

MelvinBot has made 7 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR.

Next steps: A human should review the recent commits and resolve the conflicting CI errors manually.

@ikevin127

This comment has been minimized.

@MelvinBot
MelvinBot marked this pull request as ready for review September 3, 2026 19:22
@MelvinBot
MelvinBot requested a review from a team as a code owner September 3, 2026 19:22
garrettmknight
garrettmknight previously approved these changes Sep 4, 2026

@garrettmknight garrettmknight left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from a product perspective.

tgolen
tgolen previously requested changes Sep 4, 2026
Comment on lines +155 to +156
const getReimbursementAccount = () => OnyxUtils.get(ONYXKEYS.REIMBURSEMENT_ACCOUNT);
const getReimbursementAccountDraft = () => OnyxUtils.get(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnyxUtils.get() is forbidden. We're creating an ESLint rule to prevent it in the future, but it's not merged yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 96660c5 — both calls now use the getOnyxValue test helper, and the react-native-onyx/dist/OnyxUtils import is gone. Details in the other thread.

Nothing in this PR depends on the ESLint rule landing first.

Co-authored-by: tgolen <tgolen@users.noreply.github.com>
Co-authored-by: Kevin Brian Bader <ikevin127@users.noreply.github.com>
@ikevin127

Copy link
Copy Markdown
Contributor

✅ Completed PR Reviewer Checklist. Technically this is ready to merge, but 👇

@luacmartins @mountiny Since this PR is changing logic within the Add Manual BA flow for USD accounts, I'd like to ask to have an adhoc build and have QA do both:

  • triage the adhoc on the actual issue to verify it was fixed as expected
  • run a regression test triage on the adhoc build around the Add Manual BA & Wallet flows from start to end to ensure no regressions are caused by the changes

Another reason I'm asking this besides the important app flow is because I was not able to get a manual BA in that state like the actual issue, so I had to apply local changes in order to test (this is what's shown in my recordings) - that's why is important to have somebody with an account in that state test it accordingly before approval and merge.

Callback to next steps on this PR ☝️

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@luacmartins

Copy link
Copy Markdown
Contributor

I requested QA here https://expensify.slack.com/archives/C09V78U42D8/p1788584310393389

@luacmartins

Copy link
Copy Markdown
Contributor

QA ongoing. I asked them for an ETA.

@IuliiaHerets

Copy link
Copy Markdown

Regression is complete

No issues were found during testing.

@ikevin127 ikevin127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 LGTM - QA ran regression tests and found no issues, ready to merge!

@luacmartins
luacmartins requested a review from tgolen September 9, 2026 16:25
@luacmartins
luacmartins merged commit cf387fd into main Sep 9, 2026
39 of 41 checks passed
@luacmartins
luacmartins deleted the claude-pendingUsdBankAccountSkipsContinueSetup branch September 9, 2026 16:31
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Sep 9, 2026
83 tasks done
@OSBotify

OSBotify commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.4.75-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Yes, help site changes are required. Draft PR: #100750

I found two problems in docs/articles — one caused by this PR, one a pre-existing inaccuracy in the same flow.

1. The Action required badge does not exist in the product.

Three articles told members to look for an Action required badge. That string appears nowhere in src/languages/en.ts. The real badges come from src/libs/BankAccountUtils.ts:88-125 and differ by state:

State Badge Message Action
SETUP Incomplete Finish adding bank account Finish
PENDING Pending Please confirm test transactions Confirm
VERIFYING Verifying We're reviewing your documentation —
LOCKED Locked This account requires attention Unlock

This is more than a naming nit: a member with a pending account was told to hunt for a badge that never renders, and Incomplete vs Pending is exactly what tells them whether any setup is left to finish.

2. The workspace Workflows path was undocumented.

Your redirect is gated on !!policyIDParam && achData?.policyID === policyIDParam, so it covers the workspace entry point — Workspaces > [Workspace name] > Workflows > Payments. That is the path that previously showed the Continue setup / Start over screen, and no article described it; Validate-a-Business-Bank-Account.md documented only Account > Wallet. The Wallet entry points pass no policyID and are excluded from the redirect but still reach validation, so both paths are now documented separately.

What changed in the three articles
  • Validate-a-Business-Bank-Account.md — corrected the badge to Pending with its Please confirm test transactions message and Confirm action; named the amount fields Transaction 1, Transaction 2, Transaction 3; added ## How to validate a workspace business bank account from Workflows; added ## What happens when you open a pending US business bank account explaining setup is never re-offered and why this is US-only; noted the Workspace Admin / Payments Admin requirement for the Workflows path; noted that Payments in Workflows is offline-disabled so Wallet is the offline route; fixed four Settings > Wallet references to Account > Wallet.
  • Connect-a-Business-Bank-Account.md — replaced the single "Partially set-up accounts display an Action required badge" sentence with the real four-state badge list, pointing Pending at the validation article.
  • Share-a-Business-Bank-Account.md — corrected the same Action required claim for a shared US account.
How I verified the labels (the web tester was unavailable)

The app-web-tester session could not be used — its browser page never rendered (0 accessibility nodes, blank screenshots, zero network requests over ~100s). A direct curl to the dev server returned 200, so this looks like test-infra rather than a product bug.

I verified every label against src/languages/en.ts and the components that render it instead:

  • connectBankAccountStep.validateYourBankAccount → Validate your bank account, rendered as the header title for a pending account at ConnectBankAccount.tsx:130
  • connectBankAccountStep.validateButtonText → Validate
  • connectBankAccountStep.validationInputLabel → Transaction (fields render as Transaction 1–3)
  • walletPage.bankAccountStatus.* → Pending, Incomplete, Verifying, Finish, Unlock, Please confirm test transactions
  • walletPage.personalBankAccounts / businessBankAccounts → Personal bank accounts / Business bank accounts
  • workflowsPage.makeOrTrackPaymentsTitle → Payments; bankAccount.addBankAccount → Add bank account; workspace.common.workflows → Workflows
  • common.account → Account, common.wallet → Wallet (hence Account > Wallet, not Settings > Wallet)

npm run spell-changed passes (3 files, 0 issues). Both new headings are task-based and start with a question word, only ## is used, and the one screenshot placeholder uses the non-rendered HTML comment format per HELP_AUTHORING_GUIDELINES.md.

One pre-existing violation I left in place: Validate-a-Business-Bank-Account.md has a third # heading (# Troubleshooting), which the spec allows only for the title and # FAQ. Fixing it means either demoting its children to a banned ### depth or splitting the article, so I left it rather than restructure an article beyond the scope of this change. Worth a follow-up.


@ikevin127, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@IuliiaHerets

Copy link
Copy Markdown

Hi! Regarding steps 11–13 for this PR, the QA team doesn't have access to bank statements to obtain the micro-deposit amounts.
Could you please test these steps internally?

cc @luacmartins @garrettmknight @mountiny @mjasikowski @tgolen

@luacmartins

Copy link
Copy Markdown
Contributor

@IuliiaHerets I think the main check for this PR is step 7. The remaining steps are mostly regression checks. As long as we can still validate the Open accounts, we're good.

@IuliiaHerets

Copy link
Copy Markdown

@luacmartins, all other steps are PASS; we just couldn’t verify steps 11–13.
So, can we check off this PR?

@luacmartins

luacmartins commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

@IuliiaHerets Yes

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants