Repository navigation
Skip the Continue setup step for a pending USD bank account - #100113
Conversation
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>
|
Fixed and pushed — the only real failure was
DetailsCI log: The diff: - }, [
- policyIDParam,
- achData?.currentStep,
- ...
- ]);
+ }, [policyIDParam, achData?.currentStep, shouldShowContinueSetupButtonValue, ...]);Local verification after the fix:
No browser testing was run: the change is formatting only, so there is nothing to verify at runtime. |
This comment has been minimized.
This comment has been minimized.
|
🤖 Web test steps verification results: I could only verify one of the seven checks. Steps 1–5 all need a USD bank account in the To get steps 1–5 covered, the account needs a bank account already in view run · no recording available |
|
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 Failing test: Two implementations of "next Nth of the month" disagree on the boundary day, and today is that day:
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 fromThis PR touches only:
Neither is imported by The two code paths were last changed together by the Per repo convention I'm not fixing an unrelated failure inside this PR. Reply with
|
|
The remaining failure is not from this PR. I did not fix it, since it's outside this PR's scope (this PR touches only Evidence and root causeReproduced on 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. |
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>
|
Added tests for every branch the change introduces, plus guards for the behaviour it must not alter. Pushed as
These are not vacuous. I ran both suites against
Unchanged behaviour pinned: 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 Checks run
The description said "No unit tests are added here" — I have updated that line so it no longer contradicts the branch. |
|
The Oxfmt failure is fixed (pushed in Nothing else to push here. Why the test failure is unrelatedThis PR touches only 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:
Hence the CI diff: 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 The Oxfmt fixThe
|
This comment has been minimized.
This comment has been minimized.
|
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
This PR changes four files, none of them Why it hasn't been caught before, and how to fix itIt only fires on one day a month, so most CI runs miss it. The other monthly cases in the suite assert an Worth noting the code path is also unstable on that day even by itself: The real fix is to make the two agree — have 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. |
| // 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; |
There was a problem hiding this comment.
🟠 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.
There was a problem hiding this comment.
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
policyis falsy (policy ? policy.outputCurrency : ...), and in that state the page returns theFullPageNotFoundViewatReimbursementAccountPage.tsx:635— never the entry point. SoexpectNoPendingRedirectcan'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 withpolicy?.outputCurrencyand both fail. - The narrow surviving case is a policy that loaded without an
outputCurrency, not a null policy — withpolicytruthy the fallback is skipped entirely, sopolicyCurrencyisundefinedandshouldRedirectToPendingValidationis false whilegetBankAccountConnectionStatusstill reads absent as USD. That is now pinned bydoes 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, matchingisNonUSDWorkspaceon 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).
This comment has been minimized.
This comment has been minimized.
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>
|
|
| // 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 |
There was a problem hiding this comment.
🟢 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.
There was a problem hiding this comment.
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:
tests/unit/pages/ReimbursementAccountPagePendingRedirectTest.tsx:33-40tests/unit/pages/USDVerifiedBankAccountFlowPageBackTest.tsx:29-36
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).
This comment has been minimized.
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 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. |
This comment has been minimized.
This comment has been minimized.
garrettmknight
left a comment
There was a problem hiding this comment.
Looks good from a product perspective.
| const getReimbursementAccount = () => OnyxUtils.get(ONYXKEYS.REIMBURSEMENT_ACCOUNT); | ||
| const getReimbursementAccountDraft = () => OnyxUtils.get(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); |
There was a problem hiding this comment.
OnyxUtils.get() is forbidden. We're creating an ESLint rule to prevent it in the future, but it's not merged yet.
There was a problem hiding this comment.
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>
Callback to next steps on this PR ☝️ |
|
🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
I requested QA here https://expensify.slack.com/archives/C09V78U42D8/p1788584310393389 |
|
QA ongoing. I asked them for an ETA. |
|
Regression is complete No issues were found during testing. |
ikevin127
left a comment
There was a problem hiding this comment.
🟢 LGTM - QA ran regression tests and found no issues, ready to merge!
|
🚧 luacmartins has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.4.75-0 🚀
|
|
🤖 Yes, help site changes are required. Draft PR: #100750 I found two problems in 1. The Three articles told members to look for an Action required badge. That string appears nowhere in
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 What changed in the three articles
How I verified the labels (the web tester was unavailable)The I verified every label against
One pre-existing violation I left in place: @ikevin127, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
Hi! Regarding steps 11–13 for this PR, the QA team doesn't have access to bank statements to obtain the micro-deposit amounts. cc @luacmartins @garrettmknight @mountiny @mjasikowski @tgolen |
|
@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. |
|
@luacmartins, all other steps are PASS; we just couldn’t verify steps 11–13. |
|
@IuliiaHerets Yes |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀
Bundle Size Analysis (Sentry): |


Explanation of Change
A USD bank account left in the
PENDINGstate 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)—USDBankAccountStepis write-only; no render path reads it.goToWithdrawalAccountSetupStep(VALIDATION)— despite the name, anOnyx.mergeofachData.currentStep.setShouldShowContinueSetupButton(...)— sets the flag totrue, sincehasInProgressUSDVBBAreturns true for every state that is notOPENorLOCKED,PENDINGincluded.Execution then fell through to the terminal render and painted
VerifiedBankAccountFlowEntryPointwith 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
ReimbursementAccountPagenow redirects a pending USD account to the validation page itself, rather than the caller doing it. That ordering is the point:openReimbursementAccountPageis only called from this page, andConnectBankAccountdoes no fetching of its own — it branches purely onachData.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:
ReimbursementAccountLoadingIndicator.forceReplace.forceReplacesets the action toREPLACE, which unmounts this page; its cleanup thenOnyx.setsREIMBURSEMENT_ACCOUNTtoDEFAULT_DATA(achData: {state: 'SETUP'}), which matches none ofConnectBankAccount's branches and renders the blank header-only RHP of [$250] Wallet - Blank RHP is shown after adding a Bank Account #96130.ConnectBankAccount— same blank RHP, different trigger.USDVerifiedBankAccountFlowPage's pending back press now leaves the flow. It previously went back toBANK_ACCOUNT_WITH_STEP_TO_OPEN, which resolves toReimbursementAccountPage— the page that now redirects straight back here. It usesbackTo, falling back toNavigation.dismissModal(), sinceNavigation.goBack(undefined)would pop back onto the redirector.Two guards keep the redirect from firing on the wrong account:
policyIDmust match.REIMBURSEMENT_ACCOUNTis persisted to disk, so on a cold loadachDatacan still describe a different policy's account. Entry points that pass nopolicyIDat all (WalletPagepasses only abankAccountID;BankAccountPurposePagepasses 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.The loader's back button deliberately does not reuse
goBack: that callback switches onachData.currentStep, and several of its cases only perform anOnyx.mergewith 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 realOnyx.mergeofachData.currentStep. That value is read by thestepToPageNamemap incontinueUSDVBBASetup, by thegoBackswitch, and by the route-sync effect.currentStepwill now hold whatever the server returned instead of being forced toValidationStep.Fixed Issues
$ #99998
PROPOSAL: #99998 (comment)
AI Tests
Automated checks Melvin ran locally against these changes:
npm run typechecknpm run lint-changednpm run spell-changednpm run storybook -- --smoke-test --cinpm test— 18 bank-account/reimbursement suitesnpm run react-compiler-compliance-checknpm test(full suite)ReimbursementAccountPage.tsxfails both the Babel and OXC checks with 3 × "Cannot access refs during render" onorigin/mainbefore 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 existinguseCallbackidiom still applies, which is why the new handler is memoized to match the surrounding code.USDVerifiedBankAccountFlowPage.tsxpasses both compilers before and after.--findRelatedTestsreports 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) andtests/unit/pages/USDVerifiedBankAccountFlowPageBackTest.tsx(4 tests). Both suites were also run againstorigin/main: the 9 tests asserting new behaviour fail there and pass here, and each conjunct ofshouldRedirectToPendingValidationwas mutation-checked so no guard is asserted vacuously.Tests
VERIFYINGstate, anOPENaccount, starting a fresh bank account setup, a non-USD (e.g. AUD) bank account, and the "change bank account" flow.Offline tests
Workflows cannot be used for this: the row is offline-disabled three ways (
WorkflowsPaymentsTab.tsx:202passes noonPress,:212setsdisabled: isOffline, and the "Confirm" action at:277isisActionDisabled, whichButton/index.tsx:497honours). Settings > Wallet has no offline gate at all (PaymentMethodList.tsx:624disables only the pending-delete case), so it is the reachable offline entry point.REIMBURSEMENT_ACCOUNTis cached. Go back.FormProviderdefaultingenabledWhenOffline = false, whichBankAccountValidationFormdoes not override.QA Steps
Same as tests, run against staging. Steps 1–13 in the
Testssection above require no dev-only setup — use an Expensifail account and a manually connected test bank account.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari