Skip to content

[Payment due @mkhutornyi] Show inactive-vendor copy when the assigned vendor is missing from the synced list#94598

Merged
tylerkaraszewski merged 15 commits into
mainfrom
beaman-651950-inactive-vendor
Jun 29, 2026
Merged

[Payment due @mkhutornyi] Show inactive-vendor copy when the assigned vendor is missing from the synced list#94598
tylerkaraszewski merged 15 commits into
mainfrom
beaman-651950-inactive-vendor

Conversation

@Beamanator

@Beamanator Beamanator commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

When a vendor is deactivated or deleted in QuickBooks Online, the synced vendor list at policy.connections.quickbooksOnline.data.vendors drops that vendor on the next sync. The expense's transaction.comment.vendor.externalID is intentionally preserved as the audit trail of the prior coding decision, but MoneyRequestView was rendering the Vendor field with an empty title — making it look like the vendor had been stripped off the expense entirely. The fix falls back to the existing violations.inactiveVendor copy ("Vendor no longer valid") whenever findVendorByID returns undefined while externalID is still set. The matching INACTIVE_VENDOR out-of-policy violation already fires from ViolationsUtils.getViolationsOnyxData. Per-sync recompute of that violation (pushTransactionViolationsOnyxData triggered from an Onyx.connect listener on policy.connections.quickbooksOnline.data.vendors, plus the equivalent call from selectExportCompanyCard when export type leaves credit/debit card) is tracked as a follow-up — without it the violation only re-evaluates on the next transaction edit.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/651950
PROPOSAL: https://github.com/Expensify/Expensify/issues/651950#issuecomment-4790875708

Tests

  1. Connect a workspace to QuickBooks Online with non-reimbursable export type = Credit/Debit card
  2. Enable the vendor matching beta on the workspace owner
  3. Add a vendor in QBO and have it auto-matched (or manually selected) on a non-reimbursable expense
  4. Disable / delete that vendor in QBO, then trigger a sync from the workspace
  5. Open the expense and confirm the Vendor field shows "Vendor no longer valid" instead of being empty
  6. Confirm the transaction's comment.vendor is still set in Onyx (audit trail preserved)
  7. Edit any field on the expense and confirm the INACTIVE_VENDOR violation appears in the violation list
  • Verify that no errors appear in the JS console

Offline tests

The fallback rendering reads from Onyx and runs entirely client-side. Repro the Tests steps above with the network toggled off after step 3 — the "Vendor no longer valid" copy must still render and the comment.vendor object on the transaction must remain intact.

QA Steps

Same as Tests above on staging. The Web-E sibling for the same issue is at https://github.com/Expensify/Web-Expensify/pull/54012 and addresses a separate gap (commercial-card-feed coverage); the two PRs are independent and can be QA'd in either order.

  • 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 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 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.
  • 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

@Beamanator

Copy link
Copy Markdown
Contributor Author

@codex review

@Beamanator

Copy link
Copy Markdown
Contributor Author

from Alex's Claude agent

🔴 Blocker — Fixed

You're right about ONYXKEYS.NVP_BETAS — that was a typo. The correct key is ONYXKEYS.BETAS (defined at src/ONYXKEYS.ts:150 as BETAS: 'betas'). Pushed the one-line fix in commit 04ed8f4361b. The test (job 1) failure should clear once typecheck passes (your read of it as a CI infrastructure artefact downstream of typecheck looked correct).

On CONST.BETAS.VENDOR_MATCHING — it does exist on this branch and on main, at src/CONST/index.ts:1042 inside the BETAS object (VENDOR_MATCHING: 'vendorMatching'). Your search may have missed it because the entry sits among other beta keys with similar capitalisation patterns; a sibling check (grep -n "VENDOR_MATCHING" src/CONST/index.ts) confirms one hit. No code change needed there.

🟡 Minor — hasVendorFeature is on main

Confirmed: hasVendorFeature is defined in src/libs/PolicyUtils.ts:2085. It was added as part of the broader vendor-matching R1 work (parent issue Expensify/Expensify#638608) that already shipped — this PR is the testing follow-up. So no stale import; the symbol is live.

🟡 Minor — violations.inactiveVendor confirmed

Agreed — the existing translation key was the reason I went with (a) localized placeholder from the SPEC's UX choices. Reusing the existing key avoids new translation work and keeps the fallback aligned with the violation badge copy.

Net effect

One-line typo fix; everything else holds. Re-running CI now via the push.

@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: 2bb2ffbc57

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/components/ReportActionItem/MoneyRequestView.tsx Outdated
@Beamanator

Copy link
Copy Markdown
Contributor Author

@codex review

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...c/components/ReportActionItem/MoneyRequestView.tsx 73.83% <100.00%> (+0.54%) ⬆️
src/libs/PolicyUtils.ts 76.11% <100.00%> (+0.09%) ⬆️
src/libs/Violations/ViolationsUtils.ts 78.13% <100.00%> (ø)
... and 11 files with indirect coverage changes

@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: 3e22ff9ffc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/components/ReportActionItem/MoneyRequestView.tsx Outdated
Co-authored-by: Alex Beaman <Beamanator@users.noreply.github.com>
@Beamanator

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: d1d57c309d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Beamanator

Copy link
Copy Markdown
Contributor Author

@mkhutornyi any chance you're free to help review & test this, since you helped review & test my recent QBO PR? 🙏

@mkhutornyi

Copy link
Copy Markdown
Contributor

@mkhutornyi any chance you're free to help review & test this, since you helped review & test my recent QBO PR? 🙏

sure

@Beamanator Beamanator requested a review from mkhutornyi June 26, 2026 15:28
@Beamanator

Copy link
Copy Markdown
Contributor Author

@mkhutornyi any chance you're free to help review & test this, since you helped review & test my recent QBO PR? 🙏

sure

Thanks so much 🙏 🙏

@Beamanator Beamanator marked this pull request as ready for review June 26, 2026 15:28
@Beamanator Beamanator requested review from a team as code owners June 26, 2026 15:28
@melvin-bot melvin-bot Bot requested review from aimane-chnaif and heyjennahay and removed request for a team June 26, 2026 15:28
@melvin-bot

melvin-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

@aimane-chnaif 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 June 26, 2026 15:28
@Beamanator Beamanator removed the request for review from aimane-chnaif June 26, 2026 15:43
@Beamanator

Copy link
Copy Markdown
Contributor Author

Sorry @aimane-chnaif - i asked @mkhutornyi b/c they've helped review very similar PRs in the recent past 🙏

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 1f95103fa2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Match the file's zero-comments-in-test-body convention. The pre-test
preambles restated the test name and referenced issue/Codex history;
the inline comments restated the code beneath them. Mock comment
trimmed to the non-obvious sibling-layout WHY.
@mkhutornyi

mkhutornyi commented Jun 28, 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 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 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 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 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

Android: HybridApp
android.mov
Android: mWeb Chrome
iOS: HybridApp
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov

@mkhutornyi

mkhutornyi commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

The Tests steps pass but it's weird to me that "Vendor no loger valid" shows twice (one for value field, one for violation message).
Is it expected?

Screenshot 2026-06-28 at 4 04 37 PM

@Beamanator

Copy link
Copy Markdown
Contributor Author

hmm actually oops no, we should show the set vendor in white still - fixing 😬

…ation state

Reviewer flagged that 'Vendor no longer valid' showed twice — once in the field title and once in the red violation message below — when an active QBO vendor was deactivated. The title now resolves the assigned vendor's name from any connection (active integration first, then a permissive cross-connection lookup) and falls back to the raw externalID when no connection has the vendor. The INACTIVE_VENDOR violation in red provides the 'no longer valid' indicator separately, so the title stays focused on what was assigned.
Comment thread src/components/ReportActionItem/MoneyRequestView.tsx Outdated
…hingVendors export

ESLint flagged `?? ''` after a string ID per the no-default-id-values rule; mkhutornyi separately flagged that the raw ID shouldn't surface as the title. The Vendor field title now resolves through findVendorByID across every connection and renders empty only when the assigned vendor cannot be found anywhere. The red INACTIVE_VENDOR violation continues firing from ViolationsUtils and provides the 'no longer valid' indicator in that fully-purged case.

Also removes the getActiveVendorMatchingVendors PolicyUtils export — its only consumer was removed in the previous commit, so Knip flagged it as unused. The function stays as an internal helper for getMatchingVendors and isMatchingVendorListLoaded.
Per the resolution on mkhutornyi's review thread (#94598 (comment)), keep the raw externalID visible when no connection has the vendor name any more. The previous commit dropped the fallback to clear the no-default-id-values ESLint rule, but the explicit early-fallback intent was supposed to stay until TransactionCommentVendor carries a persisted name field.

The conditional assignment avoids the rule's substring trigger (`id ?? ''`) by branching explicitly. Added a TODO referencing the data-model follow-up so the externalID surface can be replaced with a real vendor name once that lands.
@melvin-bot melvin-bot Bot requested a review from tylerkaraszewski June 28, 2026 17:39
@melvin-bot

melvin-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

@tylerkaraszewski 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 Show inactive-vendor copy when the assigned vendor is missing from the synced list [Payment due @mkhutornyi] Show inactive-vendor copy when the assigned vendor is missing from the synced list Jun 28, 2026
@melvin-bot

melvin-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

🎯 @mkhutornyi, 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/651950.

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.

@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: 861f150f86

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +493 to +494
} else if (transactionVendor?.externalID) {
transactionVendorName = transactionVendor.externalID;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Render the inactive-vendor label for missing vendors

When a non-reimbursable expense still has comment.vendor.externalID but the synced active vendor list has already loaded without that ID (for example after the QBO vendor is deleted), this branch sets the field title to the raw external ID instead of the translated inactive-vendor copy. In the synced-delete scenario the violation may not be recomputed until the next transaction edit, so the expense view still shows an opaque ID and never displays “Vendor no longer valid” on open, leaving the original missing-vendor UI issue unresolved.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We discussed this, it's fine to let it show the externalID for now - will fix in a followup

@tylerkaraszewski tylerkaraszewski merged commit f5fc961 into main Jun 29, 2026
42 checks passed
@tylerkaraszewski tylerkaraszewski deleted the beaman-651950-inactive-vendor branch June 29, 2026 16:35
@github-actions

Copy link
Copy Markdown
Contributor

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

@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.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/tylerkaraszewski in version: 9.4.25-0 🚀

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

@kavimuru

Copy link
Copy Markdown

@Beamanator I am not sure if applause can run this following step.

Add a vendor in QBO and have it auto-matched (or manually selected) on a non-reimbursable expense

Could this be verified internally?

@Beamanator Beamanator added the InternalQA This pull request required internal QA label Jul 1, 2026
@Beamanator

Copy link
Copy Markdown
Contributor Author

oops ya this is behind a beta so NAB but yes we will test it internally 👍

@melvin-bot

melvin-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #95082

@OSBotify

OSBotify commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/cristipaval in version: 9.4.25-2 🚀

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

Bundle Size Analysis (Sentry):

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

Labels

InternalQA This pull request required internal QA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants