Skip to content

Add imported vendor enable and disable controls - #103549

Merged
Beamanator merged 15 commits into
Expensify:mainfrom
ShridharGoel:stale-vendors-refetch-main
Oct 21, 2026
Merged

Beamanator merged 15 commits into
Expensify:mainfrom
ShridharGoel:stale-vendors-refetch-main

Conversation

@ShridharGoel

@ShridharGoel ShridharGoel commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR adds enable and disable controls for imported accounting vendors (re-applying Add imported vendor enable and disable controls) and fixes the two issues found during staging QA:

  1. Workspace Vendors page:
    • Add an enabled toggle column with Switch and lock support.
    • Add multi-select checkbox mode with bulk Enable and Disable actions (ButtonWithDropdownMenu).
    • Lock the default vendor toggle and exclude the default vendor from bulk disable actions.
    • Enable row interactivity when selection is active and pass canWriteVendors to selectionEnabled so long-press bulk selection works on mobile layouts.
    • Read from the policyVendors_{policyID} Onyx collection and fetch it on page open and reconnect via OpenPolicyVendorsPage so stale sessions load the vendor list.
  2. Action Layer:
    • Add setPolicyVendorsEnabled calling SetPolicyVendorsEnabled with optimistic update, success merge, and failure rollback.
    • Add clearVendorErrors for error dismissal.
    • Add openPolicyVendorsPage calling OpenPolicyVendorsPage.
  3. Expense Vendor Picker (IOURequestStepVendor):
    • Exclude disabled vendors from search results and new expense selections.
    • Keep an existing assigned disabled vendor visible in the unsearched picker list with a Disabled subtitle so the user can pick an enabled vendor or clear it with "None".
    • Fetch policyVendors_{policyID} via OpenPolicyVendorsPage when the collection is missing in Onyx.

Paired PRs:

Fixed Issues

$ #98355
$ https://github.com/Expensify/Expensify/issues/678247
$ #103529
$ #103556
PROPOSAL: N/A

Tests

  1. Log in as an admin of a workspace connected to QuickBooks Online, Sage Intacct, Xero, Certinia, DualEntry, Rillet, or Campfire with imported vendors.
  2. Make sure the Vendor Matching beta is active, then open Workspace Settings > Vendors.
  3. Verify that all imported vendors load and display an Enabled switch column.
  4. Find the default vendor (for example, the default credit card vendor in QBO or charge vendor in Intacct) and verify the switch is locked with a lock icon and cannot be turned off.
  5. Turn off a non-default vendor and verify the switch updates immediately and stays disabled after page refresh or network sync.
  6. Select multiple disabled vendors (on mobile, long-press a vendor row to enter selection mode) and use the bulk action menu to enable them.
  7. Select multiple enabled vendors (including the default vendor) and apply bulk Disable. Verify all selected vendors except the default vendor are disabled.
  8. Select both enabled and disabled vendors and verify both "Enable" and "Disable" options appear in the dropdown menu.
  9. Open an expense on the workspace and edit its vendor. Verify disabled vendors do not appear in the list or search results.
  10. On an expense assigned to a vendor that was later disabled, open the vendor picker. Verify the disabled vendor appears as selected with a "Disabled" subtitle in the unsearched list, does not appear in search results, and can be replaced with an enabled vendor or cleared with "None".
  • Verify that no errors appear in the JS console

Offline tests

  1. Open Workspace Settings > Vendors.
  2. Disconnect the network (offline mode).
  3. Toggle a vendor's Enabled switch.
  4. Verify the switch updates optimistically with a pending indicator.
  5. Reconnect the network and verify the pending indicator clears after sync.

QA Steps

Same as tests.

  • 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)
  • 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 the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/libs/API/types.ts 100.00% <ø> (ø)
src/libs/Violations/ViolationsUtils.ts 81.56% <100.00%> (+0.37%) ⬆️
src/libs/actions/IOU/UpdateMoneyRequest.ts 92.20% <ø> (ø)
src/libs/actions/Policy/Vendor.ts 100.00% <100.00%> (ø)
.../request/step/DynamicIOURequestStepDescription.tsx 80.51% <100.00%> (+0.25%) ⬆️
src/libs/PolicyUtils/vendor.ts 95.96% <97.22%> (+0.19%) ⬆️
.../components/Tables/WorkspaceVendorsTable/index.tsx 0.00% <0.00%> (ø)
...rc/pages/iou/request/step/IOURequestStepVendor.tsx 0.00% <0.00%> (ø)
...c/pages/workspace/vendors/WorkspaceVendorsPage.tsx 0.00% <0.00%> (ø)
... and 361 files with indirect coverage changes

@Beamanator

Copy link
Copy Markdown
Contributor

I reverted the main PR, sorry 🙈 Let's add those changes back to this one?

@melvin-bot

melvin-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx bun ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx bun ./scripts/generateTranslations.ts --compare-ref main

@ShridharGoel ShridharGoel changed the title Fix empty vendor list on stale sessions by fetching policyVendors on demand Add imported vendor enable and disable controls Oct 16, 2026
@ShridharGoel
ShridharGoel marked this pull request as ready for review October 16, 2026 17:35
@ShridharGoel
ShridharGoel requested review from a team as code owners October 16, 2026 17:36
@melvin-bot
melvin-bot Bot requested review from Pujan92 and removed request for a team October 16, 2026 17:36
@melvin-bot

melvin-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-10-16T17:55:04.438583Z 51739a2 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.

@melvin-bot
melvin-bot Bot requested review from garrettmknight and removed request for a team October 16, 2026 17:36
Comment thread src/pages/workspace/vendors/WorkspaceVendorsPage.tsx

@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: 51739a2ed5

ℹ️ 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/libs/Violations/ViolationsUtils.ts
Comment thread src/libs/PolicyUtils/vendor.ts
Comment thread src/pages/iou/request/step/IOURequestStepVendor.tsx Outdated
@garrettmknight
garrettmknight requested review from heyjennahay and removed request for garrettmknight October 19, 2026 09:22
@Beamanator

Copy link
Copy Markdown
Contributor

@ShridharGoel is this ready for review / testing yet? Once it's ready, i can make an adhoc build for @heyjennahay to test 🙏

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

Yes it is ready

@Beamanator

Copy link
Copy Markdown
Contributor

groovy! but yeah now github is having some outages with actions, nice

@Beamanator

Copy link
Copy Markdown
Contributor

also looks like eslint check is failing @ShridharGoel 🙏

@Beamanator

Copy link
Copy Markdown
Contributor

@Pujan92 can you review today please?

@Pujan92

Pujan92 commented Oct 21, 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: mWeb Chrome
iOS: HybridApp

#103556 - Fixed

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2026-10-22.at.00.02.00.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-10-03.at.18.55.42.mov
Screen.Recording.2026-10-03.at.18.22.29.mov

@Pujan92

Pujan92 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@ShridharGoel conflicts

…-main

# Conflicts:
#	src/libs/Violations/ViolationsUtils.ts
#	src/pages/iou/request/step/IOURequestStepVendor.tsx
#	tests/unit/ViolationUtilsTest.ts
@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@Pujan92 Fixed

@Pujan92 Pujan92 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!

@Pujan92

Pujan92 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Code review

This PR is close. I found one bug to fix before merge and a few smaller items. CI passes, apart from the approval check.

The earlier bot comments look addressed: useNetwork now refetches on reconnect, the canConfirmVendorEnabled guard keeps the violation when policyVendors isn't passed, and the eslint-disable now has a reason.

Should fix

1. Read-only users never see the read-only modal. The table passes disabled={item.disabled || item.isLocked} to the Switch with no disabledAction (WorkspaceVendorsTable/index.tsx:114). The page also sets disabled: !canWriteVendors (WorkspaceVendorsPage.tsx:200). As a result, onToggle never fires, so showReadOnlyModal() (WorkspaceVendorsPage.tsx:174) can't run. The categories table passes only disabled={item.disabled} and uses showLockIcon so the press still reaches the handler (WorkspaceCategoriesTableRow.tsx:119-125). Match that pattern. The default-vendor guard in handleVendorToggle already blocks disabling that vendor.

Minor

2. The vendor picker shows "not loaded yet" as "Disabled". isCurrentVendorDisabled = !!currentVendorID && !currentVendor?.enabled (IOURequestStepVendor.tsx:95) is also true while policyVendors is undefined. This happens on first open in a stale session, or when offline. In that case, a valid vendor gets a "Disabled" subtitle and no other vendors appear. If no vendor is set, the "no vendors" empty state shows while the fetch runs. Check policyVendors !== undefined before labelling the vendor, and consider showing a loading state while the fetch runs.

3. The fetch logic is duplicated. The useEffect body (IOURequestStepVendor.tsx:81-86) repeats fetchVendorsIfMissing (line 72).

4. A comment is now out of date. UpdateMoneyRequest.ts:866-870 says the picker offers vendors from getMatchingVendors(policy). The picker now uses the enabled entries in policyVendors.

5. The zh-hans wording is inconsistent. disableVendor uses 停用 and disableVendors uses 禁用 (zh-hans.ts:6766-6767).

I didn't run UI tests. They need a workspace with a connected accounting integration and imported vendors, plus the paired Auth and Web-Expensify changes.


view run

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Code review (follow-up)

The latest commits fix every item from my previous review. I found no new bugs. CI passes, apart from the approval check.

  • Read-only toggle: fixed. The Switch is no longer disabled, so a read-only user's tap reaches showReadOnlyModal().
  • Picker loading state: fixed. A spinner shows while policyVendors loads, and the "Disabled" label waits for the list.
  • Duplicated fetch logic, stale comment, zh-hans wording: all fixed.

Two optional follow-ups:

  1. Tapping the default vendor gives no feedback. The switch is now pressable, and WorkspaceVendorsPage.tsx:178 returns silently. The lock icon explains it, but a short modal would match how categories handle the last enabled category.
  2. Check that the spinner can't hang. Both pages show a spinner while online and policyVendors is undefined (WorkspaceVendorsPage.tsx:220, IOURequestStepVendor.tsx:97). Please confirm that OpenPolicyVendorsPage always writes policyVendors_<policyID>, using an empty object when there are no vendors. If it doesn't, the spinner never stops.

view run

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@Beamanator It's ready for your review

@Beamanator Beamanator 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! Noice!

@Beamanator
Beamanator merged commit 7ef9a7c into Expensify:main Oct 21, 2026
35 of 36 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 Beamanator 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.

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