Skip to content

[Internal QA] [Payment due @daledah] Fix company card export account selector crash on duplicate account names - #101907

Merged
MonilBhavsar merged 2 commits into
mainfrom
nicolasbonet-qbd-qbo-export-account-duplicate-keys
Sep 23, 2026
Merged

MonilBhavsar merged 2 commits into
mainfrom
nicolasbonet-qbd-qbo-export-account-duplicate-keys

Conversation

@NicolasBonet

@NicolasBonet NicolasBonet commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

QBD and QBO built their export account rows with keyForList set to the account display name. QBD routinely exposes two credit card accounts with the same name under different parents, so two rows collide on one key.

What that costs depends on the list length. On a short list the second row is silently dropped — the selector shows one entry plus an empty gap where the other should be, and that account can never be chosen. Once the list is long enough to virtualise, FlashList reports Exceeded max renders without commit, the list re-renders without committing, and React bails out with error #185, which paints "Something went wrong". Either way nothing reaches the server; the card's export account is simply unchangeable.

Every other integration already keys by id, and keyForList is only the list key — selection resolves by id — so keying QBD and QBO by id too is a drop-in fix. shouldKeyByLabel had no other callers and is removed. The QBD shouldFallBackToLabelMatch NVP behaviour is unrelated and stays.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/680784
PROPOSAL: N/A (internal)

Tests

Everything the selector renders comes from Onyx — usePolicy(policyID) and useCardsList(feed) — so a QuickBooks Desktop Web Connector and a real card feed are not needed. Dev builds expose window.Onyx (src/setup/addUtilsToWindow.ts).

  1. Open a dev build, go to Settings > Workspaces, open any workspace you administer and note the policyID from the URL.
  2. In the browser console, inject a QuickBooks Desktop connection whose chart of accounts holds two credit card accounts with the same display name and different ids:
Onyx.merge('policy_<POLICYID>', {
    connections: {
        quickbooksDesktop: {
            config: {
                export: {
                    nonReimbursable: 'CREDIT_CARD_CHARGE',
                    nonReimbursableAccount: '80000105-1',
                    reimbursable: 'CHECK',
                    reimbursableAccount: '',
                    exportDate: 'LAST_EXPENSE',
                    nonReimbursableBillDefaultVendor: '',
                },
            },
            data: {
                creditCardAccounts: [
                    {id: '80000105-1', name: 'Corporate Card', currency: 'USD'},
                    {id: '80000106-2', name: 'Corporate Card', currency: 'USD'},
                ],
            },
        },
    },
});
  1. Inject a company card on a feed, so the card details page has something to open. The feed string is <feedName>#<domainID>, and the Onyx key is cards_<domainID>_<feedName>:
Onyx.merge('cards_1_oauth.chase.com', {
    '1': {
        cardID: 1,
        state: 3,
        bank: 'oauth.chase.com',
        domainName: 'example.com',
        fraud: 'none',
        lastUpdated: '',
        lastFourPAN: '3262',
        cardName: 'Test QBD Card',
        accountID: 1,
        nameValuePairs: {quickbooks_desktop_export_account_credit: '80000106-2'},
    },
});
  1. Navigate to /workspaces/<POLICYID>/company-cards/company-card-details/oauth.chase.com%231/1. Verify the card details page renders with an Accounting section reading "QuickBooks Desktop credit card export — Corporate Card".
  2. Tap that export account row.
  3. Verify the selector lists three rows: Default card, and both Corporate Card entries, with the card's own account (80000106-2) check-marked. On main only one Corporate Card row renders and an empty gap sits where the other should be, so the second account cannot be selected at all.
  4. Select the Corporate Card row that is not currently selected, and verify the card details page updates to it. On main there is no second row to select.
  5. Repeat steps 2-7 with a QuickBooks Online connection (quickbooksOnline, creditCards for the credit card export and bankAccounts for the debit card export) and verify both same-named accounts appear and are selectable.
  6. Open the selector on a Xero, NetSuite or Sage Intacct workspace and verify it is unchanged.
  7. Check the console during steps 5-7 for Exceeded max renders without commit or React error Add link styles for sidebar footer #185. Neither should appear. On a list long enough to virtualise, the duplicate keys produce those warnings and the "Something went wrong" error screen instead of the silently dropped row.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline.
  2. Open a company card's details page and tap the export account row.
  3. Verify the selector still renders the account list from the cached connection data, with no error screen.
  4. Select an account and verify the row updates optimistically with the offline (greyed) style.

QA Steps

Needs a QuickBooks Desktop workspace whose chart of accounts contains two credit card accounts with the same display name (QBD allows this when they sit under different parents), and a company card on that workspace.

  1. Sign in as an admin of that workspace.
  2. Go to Workspace settings > Company cards and open a card's details page.
  3. Under Accounting, tap the export account row.
  4. Verify both same-named accounts are listed and neither the list nor the screen errors out.
  5. Select each of them in turn and verify the card details page shows the one you picked.
  6. Repeat on a QuickBooks Online workspace and verify selection still works.
  • 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

MacOS: Chrome / Safari

Two QuickBooks Desktop credit card accounts share the display name "Corporate Card".

Before — only one Corporate Card row renders, with an empty gap where the other should be, so that account cannot be selected:

Export account selector on main, showing Default card, an empty gap, and a single Corporate Card row

After — both accounts render, and the one the card's NVP points at is check-marked:

Export account selector with the fix, showing Default card and both Corporate Card rows

QuickBooks Desktop and QuickBooks Online built their export account rows
with keyForList set to the account display name. QBD lets two credit card
accounts share a name under different parents, so the rows collided on one
key, FlashList re-rendered without committing, and React bailed out with
'Maximum update depth exceeded' — the account selector showed
'Something went wrong' and the export account could never be changed.

Account ids are unique, so key every integration's rows by id.
@NicolasBonet
NicolasBonet marked this pull request as ready for review September 22, 2026 20:46
@NicolasBonet
NicolasBonet requested review from a team as code owners September 22, 2026 20:46
@melvin-bot
melvin-bot Bot requested review from daledah and flaviadefaria and removed request for a team September 22, 2026 20:47
@melvin-bot

melvin-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

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

@melvin-bot
melvin-bot Bot removed the request for review from a team September 22, 2026 20:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T21:00:14.148955Z 6f91c81 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f91c81b92

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/unit/CompanyCardExportTest.ts Resolved
tests/README.md asks every test case to carry Given, When and Then
comments that explain why the test is shaped the way it is.
@daledah

daledah commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

MacOS: Chrome / Safari
Screen.Recording.2026-09-23.at.14.21.01.mov

@daledah daledah left a comment

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.

LGTM

@melvin-bot
melvin-bot Bot requested a review from MonilBhavsar September 23, 2026 07:36
@melvin-bot

melvin-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

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

@melvin-bot melvin-bot Bot changed the title Fix company card export account selector crash on duplicate account names [Payment due @daledah] Fix company card export account selector crash on duplicate account names Sep 23, 2026
@melvin-bot

melvin-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

🎯 @daledah, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/680784.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

@MonilBhavsar

Copy link
Copy Markdown
Contributor

👍

@MonilBhavsar
MonilBhavsar merged commit d0d7546 into main Sep 23, 2026
36 of 39 checks passed
@MonilBhavsar
MonilBhavsar deleted the nicolasbonet-qbd-qbo-export-account-duplicate-keys branch September 23, 2026 19:09
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/MonilBhavsar in version: 9.4.93-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site changes are required, so I did not create a docs PR.

This PR changes an internal React list key only. In src/pages/workspace/companyCards/utils.tsx, normalizeAccounts now sets keyForList to the account id for QuickBooks Desktop and QuickBooks Online instead of the display name. Selection already resolved by id, so nothing a workspace admin does, sees, or names changes. It restores the behavior the help site already describes: open a company card, pick an export account, save.

What I checked

I searched docs/articles for every page that touches company card export accounts, QuickBooks Desktop, and QuickBooks Online:

  • Configure-Company-Card-Settings.md — covers Card feed name, Statement close date, Allow deleting transactions, Assign new cards, and Remove card feed. No export account content.
  • Assign-Company-Cards.md — no mention of export or accounting.
  • Configure-QuickBooks-Desktop.md and Configure-Quickbooks-Online.md — document Export company card expenses as at the workspace level, not per-card selection.
  • The QuickBooks Desktop, QuickBooks Online, NetSuite, and Certinia export-error pages — they name export accounts as a cause of export failures, never as a selector that can drop a row.

No article documents the duplicate-name symptom, and none carries a workaround that this fix would make obsolete. There is nothing to add, remove, or correct.

One pre-existing gap, unrelated to this PR: the New Expensify article QuickBooks-Desktop-FAQ.md tells readers to confirm a card's export account via Settings > Domains > Company Cards > Edit export, which is Expensify Classic navigation sitting in a new-expensify article. That was already wrong before this PR and is out of scope here. Say the word and I'll open a separate docs PR to correct it.

@NicolasBonet, I did not create a help site PR because nothing on the help site needs to change. If you think a specific article should cover this flow, tell me which one and I'll draft it.


view run

@IuliiaHerets

Copy link
Copy Markdown

Hi @NicolasBonet. QA team got this error on the first attempt on the Expensify side

QBD error - Expensify web

For the second attempt, the remote terminal froze for us

unstable.QBD.terminal-2.mp4

Is it possible to check it internally as we faced with froze issue?

cc @MonilBhavsar @flaviadefaria @daledah

@NicolasBonet

Copy link
Copy Markdown
Contributor Author

This can be handled internally @IuliiaHerets

@NicolasBonet NicolasBonet changed the title [Payment due @daledah] Fix company card export account selector crash on duplicate account names [Internal QA] [Payment due @daledah] Fix company card export account selector crash on duplicate account names Sep 24, 2026
@melvin-bot

melvin-bot Bot commented Sep 25, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #102289

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/lakchote in version: 9.4.93-3 🚀

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

Bundle Size Analysis (Sentry):

@NicolasBonet

Copy link
Copy Markdown
Contributor Author

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.

6 participants