Skip to content

Reuse the active workspace when adding a bank account to pay an invoice as a business#97047

Draft
wildan-m wants to merge 4 commits into
Expensify:mainfrom
wildan-m:wildan/92859-invoice-add-bank-account-duplicate-workspace
Draft

Reuse the active workspace when adding a bank account to pay an invoice as a business#97047
wildan-m wants to merge 4 commits into
Expensify:mainfrom
wildan-m:wildan/92859-invoice-add-bank-account-duplicate-workspace

Conversation

@wildan-m

Copy link
Copy Markdown
Contributor

Explanation of Change

When paying an invoice as a business, the "Add bank account" option resolves which workspace the bank account should be attached to. For an individual invoice receiver it reuses the active workspace only when that workspace is one the user administers and its currency is already supported for direct reimbursement — and only US dollars qualify. A payer whose workspace is in any other currency therefore fails the reuse check on every attempt, so a brand new workspace is minted each time and the account fills up with duplicates. The first press makes matters worse rather than better: the workspace it creates takes the payer's local currency, becomes the active one, and then sends the user into the currency setup screen, so the very next press hits the same failing check again and loops.

The currency check does not belong in the reuse-or-create decision. Whether a workspace is already in a supported currency governs whether direct reimbursement can be offered, not whether an in-progress workspace should be abandoned — the screen the user lands on next exists precisely to finish configuring it. Basing the decision on administration rights alone is strictly broader than the previous condition, since the old one already implied it, so every case that reused a workspace before still reuses the same one; only the looping path changes. Visibility of the option is untouched and continues to use the currency check.

Fixed Issues

$ #92859
PROPOSAL: #92859 (comment)

Tests

  1. Sign in as an invoice receiver whose local currency is not USD, and who does not administer a workspace already set to USD.
  2. Open an unpaid invoice.
  3. Click the dropdown next to the Pay button and select Pay as a business.
  4. Select Add bank account. Verify a workspace is created and you are taken into its setup flow.
  5. Return to the invoice, open the Pay dropdown again, select Pay as a business, then Add bank account.
  6. Verify you are returned to the same workspace's bank account setup flow and that no additional workspace was created — check Workspaces and confirm the count is unchanged from step 4.
  7. Repeat steps 5–6 once more and verify the workspace count still does not grow.
  8. Regression check: as a receiver who already administers a USD workspace, select Pay as a business → Add bank account and verify it still opens that existing workspace's bank account setup, exactly as before.

Offline tests

Same as tests. This change only alters which existing workspace ID is chosen before navigating, so there is no new network request and no new offline behavior. Reusing a workspace avoids the workspace-creation write entirely, so the offline path performs strictly less optimistic work than before.

QA Steps

Same as tests.

  • 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

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.

1 participant