Skip to content

Block currency changes when workspace has partially setup bank account#86075

Merged
nkuoch merged 12 commits intomainfrom
claude-fixCurrencyBlockWithPartialBankAccount
Apr 1, 2026
Merged

Block currency changes when workspace has partially setup bank account#86075
nkuoch merged 12 commits intomainfrom
claude-fixCurrencyBlockWithPartialBankAccount

Conversation

@MelvinBot
Copy link
Copy Markdown
Contributor

Explanation of Change

When a workspace has a non-US bank account that is only partially set up (via the Corpay flow), the backend correctly rejects currency changes with error "You cannot change the currency because this policy is linked to a business bank account." However, the frontend was not blocking the currency field, allowing users to attempt a change that would silently revert.

This PR uses the existing doesPolicyHavePartiallySetupBankAccount utility to also disable the currency field and block the currency selection page when the workspace has a partially-setup bank account (state is SETUP, VERIFYING, or PENDING).

Changes:

  • WorkspaceOverviewCurrencyPage.tsx: Block the page via AccessOrNotFoundWrapper when a partially-setup bank account exists for the policy
  • WorkspaceOverviewPage.tsx: Disable the currency menu item (hide right icon, disable interaction, show disabled hint text) when a partially-setup bank account exists

Fixed Issues

$ #84535
PROPOSAL: #84535 (comment)

Tests

  1. Log in with a new account
  2. Create a new workspace and set its primary currency to "AUD"
  3. Navigate to Workspace settings > Workflows > Add bank account > Connect manually
  4. Proceed through the bank account connection flow until Step 3: Business Information
  5. Enter random business name, website, and registration number
  6. Click outside the RHP to close or exit the "Connect Bank Account" flow
  7. Navigate to "Workspace Overview"
  8. Verify the currency field is disabled (no right arrow icon, not interactive, shows hint text "Your workspace currency is AUD")
  9. Try navigating directly to the currency page via deep link
  10. Verify the currency page is blocked (shows not found view)
  • Verify that no errors appear in the JS console

Offline tests

  1. Follow steps 1-7 above to create a workspace with a partially-setup bank account
  2. Go offline
  3. Navigate to Workspace Overview
  4. Verify the currency field remains disabled while offline

QA Steps

  1. Log in with a new account that does not have any bank account already added
  2. Create a new workspace and set its primary currency to "AUD"
  3. Navigate to Workspace settings > Workflows > Add bank account > Connect manually
  4. Proceed through the bank account connection flow until Step 3: Business Information
  5. Enter random details for all fields
  6. Click outside the RHP to close or exit the "Connect Bank Account" flow
  7. Navigate to "Workspace Overview"
  8. Verify the currency field is disabled and shows "Your workspace currency is AUD"
  9. Verify you cannot navigate to the currency selection page
  • 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 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

…ccount

When a non-US bank account is partially set up via the Corpay flow, the
backend correctly rejects currency changes. The frontend now also blocks
currency changes in the UI by checking for partially setup bank accounts
using the existing doesPolicyHavePartiallySetupBankAccount utility.

Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing ESLint check: replaced policy?.id ?? '' and policyID ?? '' with guarded calls (\!\!policy?.id && ... / \!\!policyID && ...) to avoid defaulting string IDs to empty strings, which violates the no-default-id-values lint rule.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing check (test job 8) is unrelated to this PR's changes.

Analysis: The job failed during the "Set up job" phase while downloading GitHub Actions dependencies (SimenB/github-actions-cpu-cores and 1Password/load-secrets-action). The errors are network-level: "Error while copying content to a stream" and "An error occurred while sending the request." No test code was ever executed.

Evidence: This is a transient GitHub Actions infrastructure/network issue. Re-running the failed job should resolve it.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing checks are unrelated to this PR's code changes.

build (New Expensify Dev, DebugDevelopment, false): Failed in the "Rock Remote Build - iOS" step. The remote cache was missing (NoSuchKey), and the fallback from-scratch compilation appears to have timed out after 25+ minutes during iOS Pod compilation (Airship, RCT-Folly). This PR only modifies two TypeScript files (WorkspaceOverviewCurrencyPage.tsx and WorkspaceOverviewPage.tsx) — no native/iOS code was changed.

test (job 8): Failed during "Set up job" while downloading GitHub Actions dependencies (1Password/load-secrets-action) with network errors (Error while copying content to a stream). This is a GitHub Actions infrastructure flake — no test code was executed.

Re-running these checks should resolve both failures.

@bernhardoj
Copy link
Copy Markdown
Contributor

@MelvinBot since the logic is duplicated, let's refactor the logic into a hook for the shouldBlockCurrencyChange

Extract the duplicated shouldBlockCurrencyChange logic from
WorkspaceOverviewCurrencyPage and WorkspaceOverviewPage into a
new useShouldBlockCurrencyChange hook.

Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Refactored the duplicated shouldBlockCurrencyChange logic into a new useShouldBlockCurrencyChange hook (src/hooks/useShouldBlockCurrencyChange.ts).

The hook encapsulates:

  • Fetching hasVBA from ONYXKEYS.REIMBURSEMENT_ACCOUNT
  • Fetching bankAccountList from ONYXKEYS.BANK_ACCOUNT_LIST
  • Computing hasPartiallySetupBankAccount via doesPolicyHavePartiallySetupBankAccount
  • Returning the combined hasVBA || hasPartiallySetupBankAccount boolean

Both WorkspaceOverviewCurrencyPage and WorkspaceOverviewPage now use useShouldBlockCurrencyChange(policyID) instead of duplicating the logic.

Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing Prettier check: sorted the useShouldBlockCurrencyChange import alphabetically in WorkspaceOverviewPage.tsx.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

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/pages/workspace/WorkspacePageWithSections.tsx 72.85% <100.00%> (-0.76%) ⬇️
...pages/workspace/invoices/WorkspaceInvoicesPage.tsx 0.00% <0.00%> (ø)
.../pages/workspace/WorkspaceOverviewCurrencyPage.tsx 0.00% <0.00%> (ø)
src/hooks/useShouldBlockCurrencyChange.ts 0.00% <0.00%> (ø)
src/pages/workspace/WorkspaceOverviewPage.tsx 0.00% <0.00%> (ø)
... and 28 files with indirect coverage changes

@bernhardoj
Copy link
Copy Markdown
Contributor

@MelvinBot since hasVBA from WorkspacePageWithSections is not being used anywhere, let's remove it.

The hasVBA parameter is no longer consumed by any child component
after the shouldBlockCurrencyChange hook refactor. Remove it from
the children type signature, computation, and the one remaining
consumer (WorkspaceInvoicesPage).

Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Removed the unused hasVBA render prop from WorkspacePageWithSections:

  • Removed hasVBA and achState computation from WorkspacePageWithSections.tsx
  • Updated the children type signature from (hasVBA, policyID, isUsingECard) to (policyID, isUsingECard)
  • Updated WorkspaceInvoicesPage.tsx which was the only consumer still accepting (but not using) the _hasVBA parameter

modals={modals}
>
{(hasVBA?: boolean) => (
{() => (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@MelvinBot I think we can remove the function style here (line 559). We can just render the component directly

Now that hasVBA is no longer consumed from the render prop,
render the children directly instead of using function style.

Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Removed the function-style render prop wrapper. Since hasVBA is no longer consumed from WorkspacePageWithSections, the children are now rendered directly as JSX instead of through a function callback.

Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing Prettier check: the children inside the <View> component in WorkspaceOverviewPage.tsx had incorrect indentation (4 extra spaces). Ran Prettier to fix the formatting.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing check (build (New Expensify Dev, DebugDevelopment, false)) is unrelated to this PR.

Analysis: This is a Remote Build iOS (xcodebuild) failure, but this PR only modifies TypeScript files:

  • src/hooks/useShouldBlockCurrencyChange.ts
  • src/pages/workspace/WorkspaceOverviewCurrencyPage.tsx
  • src/pages/workspace/WorkspaceOverviewPage.tsx
  • src/pages/workspace/WorkspacePageWithSections.tsx
  • src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx

TypeScript files are bundled by Metro, not compiled by xcodebuild. The native iOS build failure cannot be caused by these changes.

Evidence: The same Remote Build iOS workflow is also failing on other unrelated branches (claude-fixCreateReportWorkspaceDisplay, claude-autoCreateWorkspaceForTrackSignups), and even on a currently-running main branch build. This appears to be an intermittent infrastructure/build environment issue.

@bernhardoj
Copy link
Copy Markdown
Contributor

@MelvinBot Mark this PR as ready

@MelvinBot MelvinBot marked this pull request as ready for review March 23, 2026 08:11
@MelvinBot MelvinBot requested a review from a team as a code owner March 23, 2026 08:11
@melvin-bot melvin-bot bot requested review from bernhardoj and joekaufmanexpensify and removed request for a team March 23, 2026 08:11
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Mar 23, 2026

@bernhardoj 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]

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing check (build (New Expensify Dev, DebugDevelopment, false)) is unrelated to this PR's changes.

Analysis: The iOS build fails with Swift compilation errors in ios/AppDelegate.swift:

error: ambiguous implicit access level for import of 'ExpoModulesCore'; it is imported as 'internal' elsewhere
error: ambiguous implicit access level for import of 'Expo'; it is imported as 'internal' elsewhere

Evidence: This PR only modifies TypeScript files (WorkspaceOverviewCurrencyPage.tsx, WorkspaceOverviewPage.tsx, WorkspacePageWithSections.tsx, WorkspaceInvoicesPage.tsx, and useShouldBlockCurrencyChange.ts). The error is in native iOS Swift code that this PR does not touch. All other recent Remote Build iOS runs (including on main) are passing, indicating this is a transient/flaky build failure.

Recommendation: Re-run the failing check.

Copy link
Copy Markdown
Contributor

@joekaufmanexpensify joekaufmanexpensify left a comment

Choose a reason for hiding this comment

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

@bernhardoj there are no screenshots/videos in the PR, is Melvin supposed to add them?

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing check (build (New Expensify Dev, DebugDevelopment, false)) is unrelated to this PR's changes.

Analysis: The failure is in the Rock Remote Build - iOS step, which is a native iOS build infrastructure issue. This PR only modifies TypeScript files (useShouldBlockCurrencyChange.ts, WorkspaceOverviewCurrencyPage.tsx, WorkspaceOverviewPage.tsx, WorkspacePageWithSections.tsx, WorkspaceInvoicesPage.tsx), none of which affect the native iOS build.

Evidence: The same Build and deploy apps for testing workflow is consistently failing on main as well, with iOS build failures. All other checks on this PR (ESLint, TypeScript, tests, other builds) pass.

@bernhardoj
Copy link
Copy Markdown
Contributor

@joekaufmanexpensify I don't think Melvin can add them

@nkuoch
Copy link
Copy Markdown
Contributor

nkuoch commented Mar 25, 2026

@MelvinBot can you merge main into this branch?

@MelvinBot
Copy link
Copy Markdown
Contributor Author

I can only make code changes when directed by the PR author, an assignee, or an existing co-author. To have me merge main into this branch, the PR assignee (bernhardoj) should reply with a request tagging me.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing check is unrelated to this PR.

Failing check: build (New Expensify Dev, DebugDevelopment, false) — the Rock Remote Build - iOS step failed after ~25 minutes.

Analysis: This PR only modifies TypeScript files (useShouldBlockCurrencyChange.ts, WorkspaceOverviewCurrencyPage.tsx, WorkspaceOverviewPage.tsx, WorkspacePageWithSections.tsx, WorkspaceInvoicesPage.tsx) — no iOS native code, Podfile changes, or anything that could affect the iOS build.

Evidence: The same Build and deploy apps for testing workflow has recent failures on main as well (e.g. runs from 2026-03-25 03:00 UTC, 03:12 UTC, 2026-03-24 21:17 UTC), confirming this is a flaky infrastructure issue with the remote iOS build service, not caused by this PR's changes.

Re-running the failed check should resolve this.

@joekaufmanexpensify
Copy link
Copy Markdown
Contributor

@bernhardoj Could you add them then? I am interested to understand more about what this change will look like.

@bernhardoj
Copy link
Copy Markdown
Contributor

@joekaufmanexpensify I put the rec on my checklist. Here is the rec:

web.16.10.53.mp4

Copy link
Copy Markdown
Contributor

@joekaufmanexpensify joekaufmanexpensify left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing perf-tests check. The issue was a duplicate reportActions variable declaration in src/components/LHNOptionsList/OptionRowLHNData.tsx — a pre-existing problem on main introduced by the merge of PR #86644. The duplicate caused Babel to fail parsing the file, which broke the ReportActionsList and SidebarLinks perf tests. Removed the redundant second declaration.

@nkuoch
Copy link
Copy Markdown
Contributor

nkuoch commented Apr 1, 2026

@bernhardoj can you merge main to handle the conflict?

@bernhardoj
Copy link
Copy Markdown
Contributor

@MelvinBot please merge with main branch and resolve the conflict

…olve conflict

Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Merged main into this branch and resolved the conflict in src/components/LHNOptionsList/OptionRowLHNData.tsx.

Conflict details: main added a new fullReportActions hook (useOnyx keyed by fullReport?.reportID) which is used by getOptionData. The PR branch didn't have this line. Resolved by accepting the addition from main.

@bernhardoj
Copy link
Copy Markdown
Contributor

@nkuoch done

@nkuoch nkuoch merged commit ae84527 into main Apr 1, 2026
35 checks passed
@nkuoch nkuoch deleted the claude-fixCurrencyBlockWithPartialBankAccount branch April 1, 2026 10:59
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

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

@OSBotify
Copy link
Copy Markdown
Contributor

OSBotify commented Apr 1, 2026

✋ 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
Copy link
Copy Markdown
Contributor

OSBotify commented Apr 2, 2026

🚀 Deployed to staging by https://github.com/nkuoch in version: 9.3.52-0 🚀

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

Bundle Size Analysis (Sentry):

@MelvinBot
Copy link
Copy Markdown
Contributor Author

No help site changes are required for this PR.

Why:

This PR extends an existing currency-lock behavior (previously triggered only by a fully verified bank account) to also cover partially-setup bank accounts. The UI hint text is unchanged — "The default currency can't be changed because this workspace is linked to a [currency] bank account." — and already describes the restriction accurately for both cases.

The relevant help site articles are unaffected:

  • Create a company workspace — mentions setting currency during initial workspace creation, which still works fine (currency is only locked after a bank account setup begins).
  • Connect a Business Bank Account — doesn't mention currency, and adding a note about this restriction would be out of scope for a bank-account-setup guide.
  • Set Currency (Classic) — Expensify Classic only, not affected.

There is no standalone New Expensify article for changing workspace currency. The in-app hint text adequately explains the restriction to users who encounter it.

@OSBotify
Copy link
Copy Markdown
Contributor

OSBotify commented Apr 7, 2026

🚀 Deployed to production by https://github.com/roryabraham in version: 9.3.52-9 🚀

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

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.

5 participants