Skip to content

Send SetWorkspaceReimbursement when the workspace points at a different bank account - #101930

Merged
Julesssss merged 3 commits into
Expensify:mainfrom
KioCoan:fireSetWorkspaceReimbursementWhenAchAccountDiffers
Oct 7, 2026
Merged

Julesssss merged 3 commits into
Expensify:mainfrom
KioCoan:fireSetWorkspaceReimbursementWhenAchAccountDiffers

Conversation

@KioCoan

@KioCoan KioCoan commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

setWorkspaceReimbursement skips the request when the selected bank account already lists the workspace in its accountData.policyIDs. That list is built on the backend by matching routing and account numbers, so an account can list a workspace that actually points at a different bank account, for example a deleted copy of the same account held by a former admin. In that state the "Add bank account" picker offered the open account, selecting it closed the panel, nothing was sent, and the workspace could not be repaired from the UI.

The early return now also requires the workspace's own achAccount.bankAccountID to be the selected account, so the request is only skipped when both sources agree that nothing would change. Re-selecting the account the workspace already uses still sends no request and shows no loading flash, which is what the guard was added for.

A backend change (Auth) makes the workspace resolve a member's open copy on read, so this state no longer appears on the Workflows page. This App change is still needed so the picker can never silently do nothing when the workspace points elsewhere (for example when the selected copy is still pending validation, which the backend read-side substitution does not cover).

Fixed Issues

https://github.com/Expensify/Expensify/issues/682561

Tests

Reproducing the exact state needs backend setup (a policy whose stored bank account was deleted by someone who already left the workspace), so it was tested on a local dev environment built with backend commands:

  1. Workspace owner B, admin A. A adds an open business bank account and sets it as the workspace's payment account. B adds their own copy of the same account (same routing and account numbers). The payer is switched to B, A leaves the workspace, then A deletes their bank account. The workspace now stores A's deleted account while B's open copy lists the workspace in policyIDs.
  2. As B, go to Workspace > Workflows > Payments. Verify only "Add bank account" is shown (no payment account).
  3. Click "Add bank account" and select B's account from the picker.
  4. Before this change: the panel closes, no SetWorkspaceReimbursement request is sent, Payments still shows only "Add bank account".
  5. After this change: SetWorkspaceReimbursement is sent and returns 200, Payments shows the account as Active with the Payer row, and the workspace stores B's account.
  6. Open the picker again and select the same account. Verify no SetWorkspaceReimbursement request is sent.
  7. On a workspace with a normally connected bank account, toggle Payments off and on. Verify the toggle still works (this path calls the action without a bank account list).

Unit tests added to tests/actions/PolicyTest.ts: the request is sent when the workspace points at another account even though the selected account lists the workspace, and no request is sent when the selected account is already the workspace's account.

  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

The stale state cannot be created from the UI alone. Regression check on the picker and the guard:

  1. As a workspace admin who owns two open business bank accounts, go to Workspace > Workflows > Payments.
  2. Click "Add bank account" and connect the first account. Verify it appears as the payment account.
  3. Click the payment account row, choose to change the bank account, and select the second account. Verify the second account becomes the payment account with no error.
  4. Open the picker again and select the account that is already connected. Verify the panel closes, nothing changes, and no error is shown.
  5. Toggle Payments off and on. Verify the toggle works and the account stays connected.
  • 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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

Before: picker offers the open account, selecting it changes nothing
03-picker-offers-open-account
04-after-selecting-account-still-no-vba

After: selecting it sends the request and the account is connected
01-after-selecting-account-vba-connected

@KioCoan
KioCoan marked this pull request as ready for review September 24, 2026 20:52
@KioCoan
KioCoan requested review from a team as code owners September 24, 2026 20:52
@melvin-bot
melvin-bot Bot requested review from Julesssss and heyjennahay and removed request for a team September 24, 2026 20:52
@melvin-bot

melvin-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown

@Julesssss Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@Julesssss

Copy link
Copy Markdown
Contributor

Sorry for the delay @KioCoan. Would you merge main again as it's been a couple of weeks, then I'll merge

@KioCoan

KioCoan commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@Julesssss done. I also updated the PR to the new template, the CI check was failing.

@Julesssss
Julesssss merged commit fd5280f into Expensify:main Oct 7, 2026
33 of 35 checks passed
@KioCoan
KioCoan deleted the fireSetWorkspaceReimbursementWhenAchAccountDiffers branch October 7, 2026 23:47
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Oct 7, 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 Oct 8, 2026
90 tasks done
@OSBotify

OSBotify commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/Julesssss in version: 9.5.6-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed. This PR fixes a rare edge case where selecting a bank account under Workflows > Payments silently did nothing, so the app now does what users already expect and no article sentence becomes incorrect.


view run

@OSBotify

OSBotify commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.6-6 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants