Skip to content

Implement easier change of bank account#94019

Open
VickyStash wants to merge 64 commits into
Expensify:mainfrom
callstack-internal:feat/79607-easier-change-of-bank-account
Open

Implement easier change of bank account#94019
VickyStash wants to merge 64 commits into
Expensify:mainfrom
callstack-internal:feat/79607-easier-change-of-bank-account

Conversation

@VickyStash

@VickyStash VickyStash commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Workspace admins can now switch their reimbursement bank account directly from the connected/verified bank account screen, without disconnecting the current account first.

A new "Change bank account" option is added to the connected verified bank account screen. When pressed:

  • If the workspace has other eligible existing business bank accounts , the user is taken to the existing-account picker. The currently connected account is hidden from this list.
  • If there are no other eligible accounts, the user goes straight into the flow to set up a brand-new bank account.

Fixed Issues

$ #79607
PROPOSAL: N/A

Tests

  • Verify that no errors appear in the JS console

Setup: a workspace (USD) where you're an admin, and at least one business bank account already connected to your account.

1.Workflows → Payments -> Add bank account.
2. Select the account that is already set up.

Change BA → Add BA (new account) → links to workspace

  1. Workflows → Payments -> Tap on BA
  2. You will see Change bank account row. Tap on it.
  3. Tap Log into your bank account, proceed with the Plaid BA setup flow.
  4. Verify: after finishing, the newly added account is linked to Workflows → Payments for that workspace.

Change BA → pick an existing account → links to workspace

  1. Workflows → Payments -> Tap on BA
  2. You will see Change bank account row. Tap on it.
  3. Select another BA
  4. Verify selected account is now shown as the bank account for Workflows → Payments

Add partially set up bank account (add bank account, but don't provide personal info).

Change BA → pick an partially setup account

  1. Workflows → Payments -> Tap on BA
  2. You will see Change bank account row. Tap on it.
  3. Select another partially setup BA
  4. Verify selected account is now shown as the bank account for Workflows → Payments
  5. Verify you see Almost done page.
  6. Close the modal.
  7. Tap on BA.
  8. See you pushed to Almost done page with Change bank account row.
  9. Change the BA to set up BA and verify it works.

Offline tests

Same, as in Tests section

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

Same, as in Tests section

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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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_pt1.mp4
android_pt2.mp4
Android: mWeb Chrome
android_web_pt1.mp4
android_web_pt2.mp4
iOS: Native
ios_pt1.mov
ios_pt2.mov
iOS: mWeb Safari
ios_web_pt1.mov
ios_web_pt2.mov
MacOS: Chrome / Safari
web_pt1.mp4
web_pt2.mp4

koko57 and others added 25 commits February 2, 2026 11:15
…llstack-internal/Expensify-App into feat/79607-easier-change-of-bank-account
…k-internal/Expensify-App into feat/79607-easier-change-of-bank-account
# Conflicts:
#	src/pages/workspace/ConnectExistingBusinessBankAccountPage.tsx
@melvin-bot

melvin-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

# Conflicts:
#	src/libs/actions/ReimbursementAccount/index.ts
#	src/pages/ReimbursementAccount/ConnectedVerifiedBankAccount.tsx
#	src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx
#	src/pages/workspace/ConnectExistingBusinessBankAccountPage.tsx
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 94.81% <ø> (ø)
src/ONYXKEYS.ts 100.00% <ø> (ø)
src/hooks/useChangeBankAccount.ts 100.00% <100.00%> (ø)
src/libs/ExportOnyxState/common.ts 80.35% <ø> (ø)
src/libs/WorkflowUtils.ts 90.83% <100.00%> (+0.03%) ⬆️
src/libs/actions/Policy/Policy.ts 70.00% <100.00%> (-0.05%) ⬇️
src/selectors/ReimbursementAccount.ts 100.00% <100.00%> (ø)
src/ROUTES.ts 21.64% <85.71%> (+0.62%) ⬆️
...rc/libs/actions/ReimbursementAccount/navigation.ts 0.00% <0.00%> (ø)
src/libs/mapCurrencyToCountry.ts 0.00% <0.00%> (ø)
... and 7 more
... and 44 files with indirect coverage changes

@github-actions

This comment has been minimized.

Comment thread src/hooks/useChangeBankAccount.ts Outdated
@ZhenjaHorbach

ZhenjaHorbach commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #94019.

Android 🤖 iOS 🍎
⏩ SKIPPED ⏩ ⏩ SKIPPED ⏩
The build for Android was skipped The build for iOS was skipped
Web 🕸️
https://94019.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

BUG: flicker when adding new bank account

Steps

  1. Log in to an account with one USD bank account.
  2. Link that bank account to a workspace.
  3. Go to Workspace > Workflows.
  4. Tap the bank account
  5. Tap change bank account

Expected behavior

Page doesn't flicker. When you go back, you land on the "you're all set" page.

Actual behavior

Page flickers. Back button doesn't initially work. Second time closes RHP.

2026-07-14_13-03-47.mp4

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

BUG: Non-payer workspace admin can't link different bank account to workspace

Steps

  1. Login to account A and invite account B to workspace as admin.
  2. Link bank account 1 to workspace.
  3. Login to account B and confirm account has a different US bank account.
  4. Go to workspace > workflows.
  5. Tap bank account row.

Expected behavior

You see option to link existing bank account to Workspace.

Actual behavior

You see the option to add a new bank account only.

image
2026-07-14_13-09-22.mp4

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

Otherwise working very well!

Comment thread src/pages/workspace/ConnectExistingBusinessBankAccountPage.tsx Outdated
@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Review this PR

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@codex
Review this PR

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

Overall this is a well-structured feature — the shared logic is cleanly extracted into useChangeBankAccount, the selector/util changes are focused, and the hook + selector both got unit tests. The bot-flagged items (duplication, the wallet no-op row, VBBA refresh) already look addressed.

My concerns are concentrated in one place: ReimbursementAccountPage, where the "change bank account" flow reuses the same shared reimbursementAccount Onyx data as the connected-account screen and then clobbers it via prepareNewBankAccountSetup. To cope, the page now carries a web of new refs, derived state, and effects — and that is exactly the code with the least test coverage (Codecov confirms the drop there).

Main concerns

  1. Fragile route-string equality guardReimbursementAccountPage.tsx:242 gates fetchData on backTo === ROUTES.BANK_ACCOUNT_CONNECT_EXISTING_BUSINESS_BANK_ACCOUNT.getRoute(policyIDParam). This compares a fully-serialized route string, so it silently stops matching the moment backTo carries any extra param (its own backTo, a source, trailing slash, etc.). Matching on the route/screen name rather than the exact string would be far more robust.

  2. Two overlapping sources of truth for "is changing" — there's the route param isChangingBankAccount and the Onyx flag IS_CHANGING_TO_NEW_BANK_ACCOUNT (isChangingBusinessBankAccount). They model nearly the same intent but gate different branches (display gate L595/L627 vs fetch gate L304). This split is easy to get out of sync later. Worth a comment explaining why both are needed, or deriving one from the other.

  3. Several fetchData() triggers reacting to the same signals — there's now a render-phase setIsSettingBA derived from the loading transition (L131-134), an effect that refetches on that same isLoadingWorkspaceReimbursement transition (L271), a focus-based "data got clobbered" refetch (L288), and the original consume-route-intent effect now guarded by isChangingBusinessBankAccount || isLoadingWorkspaceReimbursement (L304). The code comments acknowledge the races and add guards, but correctness here rests entirely on the ordering in which the various Onyx flags settle. This is the part most likely to regress. Please double-check the fast offline→online and rapid back-navigation cases manually.

  4. Test gap on the risky code — the added tests cover the hook and selector (pure logic that was already low-risk). None cover the ReimbursementAccountPage state machine, which is where the actual complexity/risk lives. Given how race-sensitive this is, a component/integration test exercising the connected → change → (pick existing / new) → return-to-connected transitions would materially de-risk the change.

Minor / nits

  • The Policy.ts additionalData: {policyID} writes are correct with Onyx.METHOD.MERGE (verified), and the NullishDeep<BankAccountList> type change is the right call to allow policyID: null. 👍
  • The connectedBankAccount lookup in ConnectExistingBusinessBankAccountPage.tsx leans on additionalData?.policyID (an optional field) for partially-set-up accounts. It falls back to policy.achAccount.bankAccountID for fully-set-up ones, so it's fine, but it does add coupling to that field being populated — worth keeping in mind.
  • mapCurrencyToCountry returning Country | '' instead of string is a nice tightening. 👍

None of the above are blockers on their own — the feature logic looks sound. The ask is mainly (a) harden the string-equality guard, (b) a short comment reconciling the two "is changing" flags, and (c) ideally one integration test over the page's transitions given the concentrated race risk.

🤖 Generated by MelvinBot — I reviewed the diff and verified specifics against the codebase, but I did not run the app. Treat as a second opinion, not a substitute for manual QA of the flows above.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a127d7fac

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@VickyStash

Copy link
Copy Markdown
Contributor Author

Checking all of the feedback, maybe I'll try to simplify the logic! Also, I haven't solved the second reported issue yet

@VickyStash

Copy link
Copy Markdown
Contributor Author

UPD: still trying to correct the second issue.
There is one issue on the new logic side, but it also looks like there is an existing issue in the same flow. Ex: when I login from account B I see one payment account, if I clear cache and reset data I see another account:

Monosnap.screencast.2026-07-15.18-07-41.mp4

I'm figuring out what goes wrong

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants