You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Send SetWorkspaceReimbursement when the workspace points at a different bank account - #101930
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).
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:
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.
As B, go to Workspace > Workflows > Payments. Verify only "Add bank account" is shown (no payment account).
Click "Add bank account" and select B's account from the picker.
Before this change: the panel closes, no SetWorkspaceReimbursement request is sent, Payments still shows only "Add bank account".
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.
Open the picker again and select the same account. Verify no SetWorkspaceReimbursement request is sent.
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:
As a workspace admin who owns two open business bank accounts, go to Workspace > Workflows > Payments.
Click "Add bank account" and connect the first account. Verify it appears as the payment account.
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.
Open the picker again and select the account that is already connected. Verify the panel closes, nothing changes, and no error is shown.
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 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 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.
@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]
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
setWorkspaceReimbursementskips the request when the selected bank account already lists the workspace in itsaccountData.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.bankAccountIDto 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:
policyIDs.SetWorkspaceReimbursementrequest is sent, Payments still shows only "Add bank account".SetWorkspaceReimbursementis sent and returns 200, Payments shows the account as Active with the Payer row, and the workspace stores B's account.SetWorkspaceReimbursementrequest is sent.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.Offline tests
N/A
QA Steps
The stale state cannot be created from the UI alone. Regression check on the picker and the guard:
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
Before: picker offers the open account, selecting it changes nothing


After: selecting it sends the request and the account is connected
