Skip to content

[$250] Travel - Error show when toogle on the Travel Invoicing on the 2nd Workspace #83549

Closed

Description

@nlemma

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.26-4
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #83248
Email or phone of affected tester (no customers): applausetester+vq+2502@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Pixel 7 Pro /Android 16
App Component: Workspace Settings

Action Performed:

Precondition: User is not in a country with the default USD currency; use the Expensifail account

  1. Create a workspace that has an Expensify Card with a Settlement Bank Account but no Travel Invoicing configured
  2. Navigate to the Travel page for that workspace (toggle is disabled by default)
  3. Create a 2nd workspace
  4. Go to More features -> toggle on Travel
  5. Go to Travel page -> Let's go -> enter address -> Save -> Continue
  6. Go back to the App
  7. Toggle on the Travel Invoicing -> Select the bank account Plaid xxx1111
  8. Go to the Overview ( currency row is disabled)
  9. Return to the Travel page -> toggle on the Travel Invoicing again

Expected Result:

Verify that the toggle correctly shows the enabled state

Actual Result:

After toggling on the Travel Invoicing on the 2nd Workspace, it auto toggles off, and an error appears: "Travel invoicing is not configured. Please set up a USD settlement account first" and can't change the currency in the Overview: "The default currency can't be changed because this workspace is linked to a VND bank account."

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7088968_1772092717227.travel.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @ShridharGoel
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022026962151597239271
  • Upwork Job ID: 2026962151597239271
  • Last Price Increase: 2026-02-26

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 26, 2026
  2. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    Triggered auto assignment to @johncschuster (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. MelvinBot commented on Feb 26, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On a workspace created by a non-USD country user (e.g. VND), when the user enables Travel and toggles on Travel Invoicing by selecting a bank account, the toggle auto-reverts to OFF and an error appears: "Travel invoicing is not configured. Please set up a USD settlement account first." Additionally, the Overview page locks the currency field with a misleading message: "The default currency can't be changed because this workspace is linked to a VND bank account" — even though the bank account selected may actually be a USD account.

    What is the root cause of that problem?

    There are two contributing issues:

    1. No currency validation on the frontend for Travel Invoicing bank account selection

    When selecting a settlement account for Travel Invoicing, the bank account list is populated by getEligibleBankAccountsForCard() at src/libs/CardUtils.ts:363-368, which only filters by type === BUSINESS && allowDebit — it performs no currency check. The bank account list comes from the global BANK_ACCOUNT_LIST Onyx key (not per-workspace), so all of the user's business bank accounts appear regardless of currency.

    The backend's ToggleTravelInvoicing command requires a valid USD settlement account for the Travel program. When a non-USD workspace attempts to enable Travel Invoicing, the backend rejects it and returns the error in onyxData, which is then applied to cardSettings.errors and displayed under the toggle.

    2. Race condition between settlement account and toggle API calls

    In src/pages/workspace/travel/WorkspaceTravelInvoicingSettlementAccountPage.tsx:69-74, when a user selects a bank account, two API.write calls fire back-to-back without awaiting:

    1. setTravelInvoicingSettlementAccount(...) — sets the bank account
    2. toggleTravelInvoicing(...) — enables the toggle

    If the toggle command reaches the backend before the settlement account is fully saved, the backend won't see a settlement account and will reject the toggle. This contributes to the first toggle attempt failing.

    3. Misleading currency message on Overview page

    The currency disabled text at src/pages/workspace/WorkspaceOverviewPage.tsx:704-705 uses policy.outputCurrency (the workspace's own currency, e.g. VND) rather than the actual bank account's currency. The message says "linked to a VND bank account" when the bank account may actually be USD — the currencyInputDisabledText template at src/languages/en.ts:5998 just inserts whatever workspace currency is passed.

    What changes do you think we should make in order to solve the problem?

    1. Add USD currency filtering for Travel Invoicing bank account selection: Create a travel-specific bank account filter (or extend getEligibleBankAccountsForCard) that only shows USD bank accounts when selecting a settlement account for Travel Invoicing. Apply this filter in WorkspaceTravelInvoicingSettlementAccountPage.tsx and in WorkspaceTravelInvoicingSection.tsx's handleToggle eligibility check.

    2. Fix the race condition: In WorkspaceTravelInvoicingSettlementAccountPage.tsx, ensure the toggle call only fires after the settlement account API call succeeds — either by chaining them (using successData to trigger the toggle) or by moving the toggle enablement to a callback/effect that runs after settlement account confirmation.

    3. Fix the misleading currency message: In WorkspaceOverviewPage.tsx, when displaying currencyInputDisabledText, look up the actual bank account's currency from bankAccountsList using the paymentBankAccountID instead of using policy.outputCurrency.

    What alternative solutions did you explore? (Optional)

    • Block Travel Invoicing entirely for non-USD workspaces: Add a frontend guard in handleToggle that checks policy.outputCurrency === 'USD' before allowing the toggle. This is simpler but more restrictive — it prevents users from enabling Travel Invoicing even if they have a valid USD bank account and intend to change their workspace currency.

    • Backend-only fix: Improve the backend error messaging to be more descriptive about exactly what's wrong (e.g., "This workspace's currency must be USD for Travel Invoicing" vs "the bank account must be USD"). However, this alone wouldn't prevent the poor UX of the toggle auto-reverting.

    Detailed Investigation

    Evidence Chain

    1. Toggle flow: User toggles ON → handleToggle in WorkspaceTravelInvoicingSection.tsx:117-158 checks eligibility → navigates to settlement account page if needed → user selects bank account → handleSelectAccount at WorkspaceTravelInvoicingSettlementAccountPage.tsx:61-78 fires both setTravelInvoicingSettlementAccount and toggleTravelInvoicing simultaneously.

    2. Optimistic update: toggleTravelInvoicing at TravelInvoicing.ts:249-301 optimistically sets isEnabled=true and TRAVEL_US.isEnabled=true, clears errors. Toggle appears ON in the UI.

    3. Backend rejection: Backend returns non-200 jsonCode with onyxData containing {errors: {"Travel invoicing is not configured..."}} merged into PRIVATE_EXPENSIFY_CARD_SETTINGS_{workspaceAccountID}.

    4. Response processing: Per OnyxUpdates.ts:49-74, backend onyxData (with errors) is applied first, then client failureData reverts isEnabled to false. Toggle flips back to OFF and error message appears.

    5. Currency lock: setTravelInvoicingSettlementAccount optimistically writes paymentBankAccountID at root level (TravelInvoicing.ts:81). On WorkspaceOverviewPage.tsx:98-100, isBankAccountVerified = !!cardSettings?.paymentBankAccountID becomes true. The currency field is disabled with currencyInputDisabledText(policyCurrency) where policyCurrency = policy.outputCurrency = 'VND'.

    6. Second toggle attempt: User returns to Travel page → toggle is OFF (failureData reverted it) → TRAVEL_US still exists from the failed toggle attempt → hasSettlementAccount is true → handleToggle calls toggleTravelInvoicing directly → backend rejects again (confirming this is not just a race condition but a fundamental validation failure for non-USD workspaces).

    Context: PR #83248

    This bug was caught during QA of PR #83248, which tightened getTravelSettings() to require TRAVEL_US presence. That PR fixed a separate bug (#83038) where root-level Expensify Card settings were being misinterpreted as Travel Invoicing settings. PR #83248 is not the cause of this bug — the underlying issue (no USD currency validation and the race condition) existed before that PR.

    Relevant Code

    • src/libs/CardUtils.ts:363-368 — getEligibleBankAccountsForCard with no currency filter
    • src/pages/workspace/travel/WorkspaceTravelInvoicingSettlementAccountPage.tsx:61-78 — Race condition site
    • src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx:105,117-158 — Toggle handler and eligibility check
    • src/libs/actions/TravelInvoicing.ts:58-139 — setTravelInvoicingSettlementAccount (root-level write)
    • src/libs/actions/TravelInvoicing.ts:249-301 — toggleTravelInvoicing (optimistic/failure data)
    • src/pages/workspace/WorkspaceOverviewPage.tsx:169,704-705 — Misleading currency message
    • src/languages/en.ts:5998 — currencyInputDisabledText template

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 26, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 26, 2026
  6. melvin-bot commented on Feb 26, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @ShridharGoel (External)

  7. melvin-bot commented on Feb 26, 2026

    @melvin-bot
  8. changed the title [-]Travel - Error show when toogle on the Travel Invoicing on the 2nd Workspace[/-] [+][$250] Travel - Error show when toogle on the Travel Invoicing on the 2nd Workspace[/+] on Feb 26, 2026
  9. daledah commented on Feb 26, 2026

    @daledah
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    After toggling on the Travel Invoicing on the 2nd Workspace, it auto toggles off, and an error appears: "Travel invoicing is not configured. Please set up a USD settlement account first" and can't change the currency in the Overview: "The default currency can't be changed because this workspace is linked to a VND bank account."

    What is the root cause of that problem?

    The settlement account selector in WorkspaceTravelInvoicingSettlementAccountPage and the toggle handler in WorkspaceTravelInvoicingSection both use getEligibleBankAccountsForCard() to populate the bank account list. This function only filters by type === BUSINESS && allowDebit — it does not check currency.

    const eligibleBankAccounts = getEligibleBankAccountsForCard(bankAccountsList);

    (

    const eligibleBankAccounts = getEligibleBankAccountsForCard(bankAccountList);

    Travel Invoicing (PROGRAM_TRAVEL_US) requires a USD settlement account, but the frontend shows all business bank accounts regardless of currency. When a non-USD account is selected, the backend correctly rejects the toggle, causing it to auto-revert. Additionally, the optimistic paymentBankAccountID set by setTravelInvoicingSettlementAccount at the root level of cardSettings persists even after the toggle failure (the failureData only reverts isEnabled), causing the Overview page to lock the currency field with a misleading message using policy.outputCurrency (VND) instead of the actual bank account currency.

    What changes do you think we should make in order to solve the problem?

    Add a new getEligibleBankAccountsForTravelInvoicing() function in CardUtils.ts that filters by bankCurrency === USD, following the existing getEligibleBankAccountsForUkEuCard pattern. Then replace getEligibleBankAccountsForCard with this new function in both Travel Invoicing files.

    In src/libs/CardUtils.ts:

    +function getEligibleBankAccountsForTravelInvoicing(bankAccountsList: OnyxEntry<BankAccountList>) {
    +    if (!bankAccountsList || isEmptyObject(bankAccountsList)) {
    +        return [];
    +    }
    +    return Object.values(bankAccountsList).filter(
    +        (bankAccount) =>
    +            bankAccount?.accountData?.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS &&
    +            bankAccount?.accountData?.allowDebit &&
    +            bankAccount?.bankCurrency === CONST.CURRENCY.USD,
    +    );
    +}

    In src/pages/workspace/travel/WorkspaceTravelInvoicingSettlementAccountPage.tsx:

    -import {getEligibleBankAccountsForCard} from '@libs/CardUtils';
    +import {getEligibleBankAccountsForTravelInvoicing} from '@libs/CardUtils';
    
    -    const eligibleBankAccounts = getEligibleBankAccountsForCard(bankAccountsList);
    +    const eligibleBankAccounts = getEligibleBankAccountsForTravelInvoicing(bankAccountsList);

    In src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx:

    -import {getEligibleBankAccountsForCard} from '@libs/CardUtils';
    +import {getEligibleBankAccountsForTravelInvoicing} from '@libs/CardUtils';
    
    -    const eligibleBankAccounts = getEligibleBankAccountsForCard(bankAccountList);
    +    const eligibleBankAccounts = getEligibleBankAccountsForTravelInvoicing(bankAccountList);

    What alternative solutions did you explore? (Optional)

    Add an optional currency parameter to the existing getEligibleBankAccountsForCard(). However, a separate function follows the existing pattern (see getEligibleBankAccountsForUkEuCard) and avoids affecting other callers.

  10. rlinoz commented on Feb 26, 2026

    @rlinoz
    Contributor

    I believe this is being solved by another PR cc: @blimpich

    I will also re-assign because this is part of the travel invoicing project.

  11. removed
    ExternalAdded to denote the issue can be worked on by a contributor
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 26, 2026
  12. blimpich commented on Feb 26, 2026

    @blimpich
    Contributor

    Yeah this will be solved by the 1:1:1 work I'm doing here: #81470. Closing this since this is (A) being handled elsewhere and (B) is behind a beta

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions