Skip to content

[Due for payment 2026-11-02] w37-Invoice-Default badge is missing and Make default payment method shown for Primary Default BA #101694

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.90-0
Reproducible in staging?: Yes
Reproducible in production?: Unable to validate in Prod - Provide reasoning.
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/73478682/folder/13176671/54433743/1748448733?sort=%2Bidentifier&status_id=1014144
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Windows 10 / Chrome
App Component: Other

Action Performed:

Precondition: Invoices is enable in Workspace and add a verified bank account in Invoices Bank account section

  1. Navigate to Invoices > Bank Account section
  2. Click on the three dot and verify that the "Make default payment method" option is completely hidden for one account.
  3. Click on Add Bank Account and complete the plaid flow
  4. After adding second BA, verify the primary bank account row displays a "Default" visual badge.
    Result: Default badge is not displayed
  5. Click on the three dot of Primary Default Acount
  6. Verify that the "Make default payment method" option is hidden inside the three-dot menu for this primary default bank account row
    Result: Make default option is shown for primary default account

Expected Result:

After adding second BA, the primary bank account row displays a "Default" visual badge and Make default option is not shown for primary default account

Actual Result:

After adding second BA, Default badge is not displayed and Make default option is shown for primary default account

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

bandicam.2026-09-21.10-20-17-444.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7263553

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. applause-bot commented on Sep 21, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/e21af11337954fba98009b3e091facd12764dd07af713724eeab33ab3388c5bb

  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 21, 2026
  3. MelvinBot commented on Sep 21, 2026

    @MelvinBot
    Contributor

    Updated 2026-10-13: Corrected based on feedback from TaduJR and yuwenmemon.

    Proposal

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

    After a workspace has two business bank accounts in Invoices > Bank account, no row shows the "Default" badge, and every row, including the primary one, offers "Make default payment method".

    What is the root cause of that problem?

    App treats an account as the invoice default only when policy.invoice.bankAccount.transferBankAccountID matches it (WorkspaceInvoiceVBASection.tsx:66). That saved ID often matches no eligible account, for two reasons:

    1. It's never saved when an account is added. OpenPolicyInvoicesPage returns no transferBankAccountID before or after adding an account, so App falls back to 0.
    2. It's kept after the account is deleted. TaduJR deleted the saved default on staging, and OpenPolicyInvoicesPage still returned the deleted ID.

    Either way, no row matches the ID. No row gets the badge (PaymentMethodList.tsx:694), and shouldShowMakeDefaultButton is true on every row once two accounts exist.

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

    Fix it in App only. App saves nothing until the user presses "Make default".

    1. In WorkspaceInvoiceVBASection, derive the invoice default:
      • Use the saved transferBankAccountID while it matches an eligible account.
      • Otherwise, use the first eligible account that isn't being deleted (its pendingAction isn't DELETE). This keeps the badge off a struck-through row that was deleted while offline.
    2. Use the derived ID in two places:
      • To decide whether the selected row is the default (isSelectedPaymentMethodDefault), which hides "Make default" on that row.
      • As the invoiceTransferBankAccountID prop of PaymentMethodList (line 286), which shows the badge.
    3. Leave deletePaymentMethod and the activePaymentMethodID prop unchanged.
      • deletePaymentMethod should keep comparing against the saved ID. If it used the derived ID, deleting an unsaved derived default would save the next account with the deleted account as the rollback value. A failed request would then make the deleted account the saved default.
      • activePaymentMethodID has no effect in this section, because the section doesn't pass actionPaymentMethodType (PaymentMethodList.tsx:158-159).
    4. In makeDefaultPaymentMethod, pass the saved transferBankAccountID as the rollback value instead of the Wallet's default account. Today a failed request puts the badge on the Wallet default, which has nothing to do with invoices. Keep the currentPaymentMethod lookup and the formatPaymentMethods import: paymentMethod.methodID is string | number, and setInvoicingTransferBankAccount needs a number.
    5. Add UI tests to tests/ui/WorkspaceInvoiceVBASectionTest.tsx:
      1. No saved default: the first eligible account shows the badge, and its menu offers Delete but not "Make default".
      2. No saved default: the second account still offers "Make default".
      3. No saved default, offline, with the first account being deleted: the badge moves to the second account.
      4. A saved default on the second account: the badge follows it.
      5. A saved default whose account was deleted: the first eligible account shows the badge, and its menu offers Delete but not "Make default".
      6. "Make default" fails (the server answers with jsonCode 666): one request is sent, and the badge goes back to the saved default, not the Wallet default.

    Open question: If invoice payouts go to the workspace's reimbursement account (policy.achAccount), step 1 should prefer that account, when it's eligible, over the first eligible account. An internal engineer needs to confirm this.

    What alternative solutions did you explore? (Optional)

    • Save the default on the backend (this proposal's previous version). Rejected: yuwenmemon confirmed nothing on the server uses this value to move money. A backend save and backfill would store a value that only App reads.
    • Use the derived ID in deletePaymentMethod too. Rejected: a failed request can make the deleted account the saved default (see step 3).
    • Change only the falsy 0 check in PaymentMethodList.tsx:694. Rejected: no account matches 0 or a deleted ID, so the badge still doesn't show.

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/101694#issuecomment-5757222080) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 21, 2026
  5. melvin-bot commented on Sep 21, 2026

    @melvin-bot

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

  6. melvin-bot commented on Sep 21, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. melvin-bot commented on Sep 24, 2026

    @melvin-bot

    @TaduJR Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  8. ashusatyarthi-wq commented on Sep 27, 2026

    @ashusatyarthi-wq

    Proposal

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

    In Workspace Settings > Invoices > Bank Account:
    After adding a second verified business bank account, the primary (first) bank account does not display the "Default" visual badge, and opening the three-dot menu on the primary bank account unexpectedly shows the "Make default payment method" option.

    What is the root cause of that problem?

    There are two core root causes working together:

    1. Unassigned Initial Invoicing Default in WorkspaceInvoiceVBASection.tsx:
      In src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx (lines 64–72):

      const transferBankAccountID = policy?.invoice?.bankAccount?.transferBankAccountID ?? CONST.DEFAULT_NUMBER_ID;
      ...
      const hasInvoiceDefaultBankAccount = transferBankAccountID !== CONST.DEFAULT_NUMBER_ID;

      When a workspace connects business bank accounts, policy.invoice.bankAccount.transferBankAccountID is initially unset (undefined / 0). The backend and frontend expect the first eligible business bank account added to the workspace to act as the primary invoice default.
      Because transferBankAccountID remains 0:

      • transferBankAccountID === methodID (line 110) evaluates to false for every bank account. Consequently, paymentMethod.isSelectedPaymentMethodDefault is always false.
      • As soon as a second bank account is added (hasMultipleEligibleBankAccounts becomes true), shouldShowMakeDefaultButton (line 72) evaluates to true for both bank accounts.
      • transferBankAccountID (0) is passed down to PaymentMethodList as invoiceTransferBankAccountID.
    2. Falsy Guard Fallback in PaymentMethodList.tsx:
      In src/pages/settings/Wallet/PaymentMethodList.tsx (lines 695–699):

      shouldShowDefaultBadge={shouldShowDefaultBadge(
          filteredPaymentMethodsWithoutStrings,
          invoiceTransferBankAccountID ? invoiceTransferBankAccountID === item.methodID : item.methodID === userWallet?.walletLinkedAccountID,
          shouldHideDefaultBadge,
      )}

      Because invoiceTransferBankAccountID is 0 (falsy), the ternary expression bypasses the workspace invoice check and falls back to checking item.methodID === userWallet?.walletLinkedAccountID (the personal wallet default). Since a business bank account added for workspace invoicing never matches the personal wallet's linked account ID, neither account gets the "Default" badge.

    3. Secondary Rollback Defect in makeDefaultPaymentMethod:
      In WorkspaceInvoiceVBASection.tsx (lines 135–140):

      const paymentMethods = formatPaymentMethods(bankAccountList ?? {}, {}, styles, translate);
      const previousPaymentMethod = paymentMethods.find((method) => !!method.isDefault);

      formatPaymentMethods sets method.isDefault based on personal wallet defaults (userWallet?.walletLinkedAccountID), NOT workspace invoicing defaults. Thus, previousPaymentMethod reverts to the personal wallet's bank account or 0 on error instead of the actual previous invoicing default.


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

    1. Derive Effective Invoice Default in WorkspaceInvoiceVBASection.tsx:
      In src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx:

      • Derive the fallback default from the first eligible business bank account if no explicit default has been persisted yet:
        const defaultEligibleBankAccountID = eligibleBusinessBankAccounts.at(0)?.accountData?.bankAccountID;
        const effectiveTransferBankAccountID = transferBankAccountID !== CONST.DEFAULT_NUMBER_ID 
            ? transferBankAccountID 
            : (defaultEligibleBankAccountID ?? CONST.DEFAULT_NUMBER_ID);
      • Use effectiveTransferBankAccountID to evaluate default status and pass to PaymentMethodList:
        • Line 70: const hasInvoiceDefaultBankAccount = effectiveTransferBankAccountID !== CONST.DEFAULT_NUMBER_ID;
        • Line 71: const isInvoiceDefaultBankAccountMissing = hasInvoiceDefaultBankAccount && !eligibleBusinessBankAccounts.some((account) => account.accountData?.bankAccountID === effectiveTransferBankAccountID);
        • Line 110: isSelectedPaymentMethodDefault: effectiveTransferBankAccountID === methodID,
        • Lines 284–285:
          invoiceTransferBankAccountID={effectiveTransferBankAccountID}
          activePaymentMethodID={effectiveTransferBankAccountID}
      • In makeDefaultPaymentMethod (lines 133–142), use effectiveTransferBankAccountID as the previous default parameter for setInvoicingTransferBankAccount:
        const makeDefaultPaymentMethod = useCallback(() => {
            const currentPaymentMethod = eligibleBusinessBankAccounts.find((account) => account.accountData?.bankAccountID === paymentMethod.methodID);
            if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && currentPaymentMethod?.accountData?.bankAccountID) {
                setInvoicingTransferBankAccount(currentPaymentMethod.accountData.bankAccountID, policyID, effectiveTransferBankAccountID);
            }
            resetSelectedPaymentMethodData();
        }, [eligibleBusinessBankAccounts, paymentMethod.selectedPaymentMethodType, paymentMethod.methodID, policyID, effectiveTransferBankAccountID, resetSelectedPaymentMethodData]);
      • In deletePaymentMethod (line 126), update the default check to use effectiveTransferBankAccountID === bankAccountID.
    2. Fix Explicit Falsy Check in PaymentMethodList.tsx:
      In src/pages/settings/Wallet/PaymentMethodList.tsx (line 697):
      Check invoiceTransferBankAccountID !== undefined:

      shouldShowDefaultBadge={shouldShowDefaultBadge(
          filteredPaymentMethodsWithoutStrings,
          invoiceTransferBankAccountID !== undefined ? invoiceTransferBankAccountID === item.methodID : item.methodID === userWallet?.walletLinkedAccountID,
          shouldHideDefaultBadge,
      )}

      This prevents accidental fallback to personal wallet default when invoiceTransferBankAccountID is provided.


    What alternative solutions did you explore? (Optional)

    • Writing to Onyx / API on mount: Firing a network mutation (setInvoicingTransferBankAccount) on component render when transferBankAccountID is missing is an anti-pattern that triggers unnecessary API roundtrips and side-effects. Deriving effectiveTransferBankAccountID from the eligible business accounts array guarantees synchronous UI accuracy and clean optimistic updates when the user switches defaults.
  9. ashusatyarthi-wq commented on Sep 27, 2026

    @ashusatyarthi-wq

    Live Compare Branch & Patch

    For convenient verification, I have published a working patch branch against latest main:
    🔗 Compare: main...ashusatyarthi-wq:App:fix/invoice-default-ba-badge-101694

    • Derives effectiveTransferBankAccountID from the first eligible business bank account when no explicit default has been persisted yet.
    • Accurately renders the "Default" badge and hides "Make default payment method" on the primary account.
    • Guards against falsy 0 fallback in PaymentMethodList.tsx (invoiceTransferBankAccountID !== undefined).
  10. 48 remaining items

  11. melvin-bot commented on Nov 5, 2026

    @melvin-bot

    @mallenexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

  12. mallenexpensify commented on Nov 5, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @yusufdeveloper2903 paid $175 via Upwork
    Contributor+: @TaduJR paid $175 via Upwork.

    Both, can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022118168844059773432

    $175 cuz Help Wanted wasn't added, which is currently a requirement

    @TaduJR plz complete the Contributor+ checklist and tag me in a post once you have. Thx

  13. melvin-bot commented on Nov 5, 2026

    @melvin-bot

    @mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  14. yusufdeveloper2903 commented on Nov 5, 2026

    @yusufdeveloper2903
    Contributor

    @mallenexpensify Thanks! I've accepted the job offer on Upwork

  15. mallenexpensify commented on Nov 6, 2026

    @mallenexpensify
    Contributor

    @yusufdeveloper2903 paid, summary updated above. Thx.

    @TaduJR can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022118168844059773432

  16. jeffrey-graham commented on Nov 7, 2026

    @jeffrey-graham
  17. melvin-bot commented on Nov 7, 2026

    @melvin-bot
  18. TaduJR commented on Nov 9, 2026

    @TaduJR
    Contributor

    Contributor+ checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to the comment on the PR: fix: allow adding a second bank account for invoices #91167 (comment)
      Link to the comment on the Issue:

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A. Not critical: the badge and the extra menu option don't block any flow, and the invoice default doesn't move money.

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    The existing test from #76723 caught this bug. We should update it to the steps below, which add the check that "Make default" moves the badge.

    Regression Test Proposal

    Precondition:

    • A workspace with Invoices enabled and one verified business bank account added in Invoices > Bank accounts.

    Test:

    1. Go to Workspace > Invoices > Bank accounts.
    2. Open the three-dot menu on the bank account and verify "Make default payment method" isn't shown.
    3. Click "Add bank account" and complete the Plaid flow for a second business bank account.
    4. Verify the first bank account shows the "Default" badge.
    5. Open the first bank account's three-dot menu and verify "Make default payment method" isn't shown.
    6. Open the second bank account's three-dot menu and verify "Make default payment method" is shown.
    7. Click "Make default payment method" and verify the "Default" badge moves to the second bank account.

    Do we agree 👍 or 👎

  19. TaduJR commented on Nov 9, 2026

    @TaduJR
    Contributor

    Offer Accepted @mallenexpensify

    Thanks!

  20. mallenexpensify commented on Nov 9, 2026

    @mallenexpensify
    Contributor

    @TaduJR paid, summary updated above. Thx.

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions