Skip to content

Conversation

@mountiny
Copy link
Contributor

@mountiny mountiny commented Feb 10, 2026

Explanation of Change

Stale direct feeds (OAuth/Plaid) and orphaned legacy feeds are showing in the App when companyCards entries exist but the feeds are no longer valid. This happens due to race conditions in the backend's non-atomic domain_member NVP updates (_setNamed in PHP does a read-modify-write that can orphan companyCards entries).

This PR introduces a three-tier feed visibility system that classifies feeds and filters them accordingly:

  1. isDirectFeed() helper — aligned with the backend's Card::isOAuthBank / Card::isPlaidBank: feeds starting with oauth or plaid.

  2. isCustomFeed() helper — identifies commercial feeds: VCF (vcf), CDF (cdf), GL1025 (gl1025), GL1205 (gl1205), Amex Direct (amex).

  3. Three-tier visibility rules applied in both getOriginalCompanyFeeds() and getCombinedCardFeedsFromAllFeeds():

    • Commercial feeds (isCustomFeed): always shown — these are file-based and don't depend on OAuth state.
    • Direct feeds (isDirectFeed): shown if they have oAuthAccountDetails OR assigned cards in WORKSPACE_CARDS_LIST.
    • Gray-zone feeds (neither commercial nor direct, e.g. capitalonecards, americanexpressfd.us, ccupload*, stripe): shown only if they have assigned cards.
  4. Performance-optimized card lookup — instead of passing the entire WORKSPACE_CARDS_LIST collection through utility functions, a feedKeysWithAssignedCardsSelector in selectors/Card.ts precomputes a lightweight Record<string, true> map of "${domainID}_${feedName}" keys for O(1) lookup. This selector is used with useOnyx across all hooks/components that display feeds.

  5. feedHasCards() helper — performs O(1) check against the precomputed map to determine if a feed has any assigned cards.

  6. feedKeysWithCards threaded through all display and search hooks/components: useCardFeeds, useCardFeedsForDisplay, SearchUIUtils, SearchQueryUtils, SearchAutocompleteList, SearchFiltersBar, SearchPageHeaderInput, SearchTypeMenu, useSearchTypeMenu, and cardFeedErrors derived config.

  7. 40+ unit tests covering all feed type classifications, the stale feed filtering behavior, gray-zone feed filtering, and the feedKeysWithAssignedCardsSelector.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/596739

Tests

  1. Navigate to a workspace that has company card feeds configured (both commercial like VCF/CDF and direct like Chase/CapitalOne)
  2. Verify that all valid feeds with proper oAuthAccountDetails still appear in the company cards page
  3. Verify that commercial feeds (VCF, CDF, GL1025, GL1205, etc.) appear regardless of oAuthAccountDetails or assigned cards
  4. Verify that direct feeds (OAuth/Plaid) appear if they have oAuthAccountDetails or assigned cards
  5. Verify that direct feeds without oAuthAccountDetails AND without assigned cards are hidden
  6. Verify that gray-zone feeds (e.g. capitalonecards, americanexpressfd.us, stripe, ccupload*) are hidden when they have no assigned cards
  7. Verify that gray-zone feeds with assigned cards are shown
  8. Run npm test -- --testPathPattern="tests/unit/CardUtilsTest.ts" and verify all tests pass
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline and navigate to the company cards page
  2. Verify that all valid feeds still display correctly from cached Onyx data
  3. Verify that stale direct feeds (missing oAuthAccountDetails and no assigned cards) are still filtered out even when offline
  4. Verify that gray-zone feeds without assigned cards remain hidden offline

QA Steps

  1. Log in to an account that has a workspace with both commercial and direct card feeds
  2. Navigate to Settings > Workspaces > [Workspace] > Company cards
  3. Verify all valid feeds appear (commercial feeds like VCF/CDF and direct feeds like Chase/CapitalOne with proper OAuth details or assigned cards)
  4. Verify no stale/orphaned direct feeds appear (direct feeds without oAuthAccountDetails and no assigned cards should be hidden)
  5. Verify gray-zone feeds (neither commercial nor direct) only appear when they have assigned cards
  6. Check the search filters (company card feed dropdowns) to confirm they also reflect the same feed visibility rules
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

N/A - Logic-only change with no UI modifications

Android: mWeb Chrome

N/A - Logic-only change with no UI modifications

iOS: Native

N/A - Logic-only change with no UI modifications

iOS: mWeb Safari

N/A - Logic-only change with no UI modifications

MacOS: Chrome / Safari

N/A - Logic-only change with no UI modifications

@mountiny mountiny requested review from a team as code owners February 10, 2026 22:23
@melvin-bot melvin-bot bot requested review from JmillsExpensify and ShridharGoel and removed request for a team February 10, 2026 22:23
@melvin-bot
Copy link

melvin-bot bot commented Feb 10, 2026

@ShridharGoel 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 February 10, 2026 22:23
Copy link

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

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: fac9390e52

ℹ️ 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".

Direct feeds (OAuth/Plaid) require oAuthAccountDetails to be functional.
Due to race conditions in the backend's non-atomic domain_member NVP updates,
companyCards entries can become orphaned when oAuthAccountDetails is removed
but the companyCards key remains. This adds an isDirectFeed helper (matching
the backend's isOAuthBank/isPlaidBank prefix checks) and filters out stale
direct feeds in getOriginalCompanyFeeds and getCombinedCardFeedsFromAllFeeds.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mountiny
Copy link
Contributor Author

@codex review

@mountiny mountiny requested a review from nkuoch February 10, 2026 22:54
@mountiny
Copy link
Contributor Author

I will need to test with one of the accounts that reported this issue

@github-actions
Copy link
Contributor

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

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

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

Files with missing lines Coverage Δ
src/components/Search/SearchAutocompleteList.tsx 32.59% <100.00%> (+0.18%) ⬆️
...nents/Search/SearchPageHeader/SearchFiltersBar.tsx 65.80% <100.00%> (+0.11%) ⬆️
.../Search/SearchPageHeader/SearchPageHeaderInput.tsx 36.89% <100.00%> (+0.33%) ⬆️
src/hooks/useCardFeeds.tsx 88.88% <100.00%> (+1.38%) ⬆️
src/hooks/useCardFeedsForDisplay.ts 73.91% <100.00%> (+1.18%) ⬆️
src/hooks/useSearchTypeMenu.tsx 69.73% <100.00%> (+0.40%) ⬆️
src/libs/CardUtils.ts 76.22% <100.00%> (+0.99%) ⬆️
src/libs/SearchUIUtils.ts 64.08% <100.00%> (ø)
...libs/actions/OnyxDerived/configs/cardFeedErrors.ts 97.10% <100.00%> (+0.04%) ⬆️
src/selectors/Card.ts 100.00% <100.00%> (ø)
... and 3 more
... and 9 files with indirect coverage changes

@github-actions

This comment has been minimized.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ 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".

robertjchen
robertjchen previously approved these changes Feb 10, 2026
@ShridharGoel
Copy link
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 there are no new alerts related to the canBeMissing param for useOnyx
  • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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
iOS: mWeb Safari
MacOS: Chrome / Safari Screenshot 2026-02-11 at 12 27 57 PM

@melvin-bot melvin-bot bot requested a review from aldo-expensify February 11, 2026 06:59
@melvin-bot
Copy link

melvin-bot bot commented Feb 11, 2026

@aldo-expensify 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
Copy link

melvin-bot bot commented Feb 11, 2026

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

An E/App issue has been created to issue payment here: #82081.

nkuoch
nkuoch previously approved these changes Feb 11, 2026
@mountiny mountiny changed the title Filter out stale direct feeds missing oAuthAccountDetails [WIP] Filter out stale direct feeds missing oAuthAccountDetails Feb 11, 2026
Replace passing full OnyxCollection<WorkspaceCardsList> through the
feed utility chain with a lightweight FeedKeysWithAssignedCards map
(Record<string, true>) for O(1) lookup. This avoids unnecessary
re-renders when individual card details change and reduces memory
overhead at each call site.

- Add feedKeysWithAssignedCardsSelector in selectors/Card.ts
- Refactor directFeedHasCards to use O(1) key lookup
- Thread feedKeysWithCards through CardFeedUtils, SearchQueryUtils,
  SearchUIUtils and all consuming components/hooks
- Add comprehensive tests for the new selector

Co-authored-by: Cursor <cursoragent@cursor.com>
@mountiny mountiny dismissed stale reviews from nkuoch and robertjchen via bcb9dd4 February 11, 2026 14:02
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #82056.

Android 🤖 iOS 🍎
⏩ SKIPPED ⏩ ⏩ SKIPPED ⏩
The build for Android was skipped The build for iOS was skipped
Web 🕸️
https://82056.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #82056.

Android 🤖 iOS 🍎
⏩ SKIPPED ⏩ ⏩ SKIPPED ⏩
The build for Android was skipped The build for iOS was skipped
Web 🕸️
https://82056.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

@mountiny
Copy link
Contributor Author

the builds are not clearing cache so its hard to test

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #82056.

Android 🤖 iOS 🍎
⏩ SKIPPED ⏩ ⏩ SKIPPED ⏩
The build for Android was skipped The build for iOS was skipped
Web 🕸️
https://16ed807a01676b33c2aefd9b987e2c9574fdd41f.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

@mountiny
Copy link
Contributor Author

Ok first I had to fix the adhoc builds https://github.com/Expensify/App/pull/82240/changes

to run the test, for this user that is showing correctly now

image

@mountiny
Copy link
Contributor Author

@codex review

@mountiny mountiny added the InternalQA This pull request required internal QA label Feb 12, 2026
Copy link

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

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: 15fa8f2f3e

ℹ️ 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".

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #82056.

Android 🤖 iOS 🍎
⏩ SKIPPED ⏩ ⏩ SKIPPED ⏩
The build for Android was skipped The build for iOS was skipped
Web 🕸️
https://a1bdf7a09da07b91f8fcda2b106d48b5217b4252.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

Resolve import conflict in SearchUIUtils.ts (keep FeedKeysWithAssignedCards
type import and expanded date-fns imports from main) and accept main's
Mobile-Expensify submodule ref.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mountiny
Copy link
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

We were unable to download your code in a timely manner.
ℹ️ 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".

Resolve Mobile-Expensify submodule conflict (accept main's ref).

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #82056.

Android 🤖 iOS 🍎
⏩ SKIPPED ⏩ ⏩ SKIPPED ⏩
The build for Android was skipped The build for iOS was skipped
Web 🕸️
https://92496e9f5fd14b279de40c2e96da9b11f81cd592.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

mountiny and others added 2 commits February 12, 2026 17:34
The submodule pointer was inadvertently changed by a prior commit on this
branch. Reset it to match main's current ref so the PR has no submodule diff.

Co-authored-by: Cursor <cursoragent@cursor.com>
@nkuoch
Copy link
Contributor

nkuoch commented Feb 12, 2026

Summary

This PR by @mountiny introduces a three-tier feed visibility system to filter out stale OAuth/Plaid feeds and orphaned legacy feeds from the company cards UI. The issue arises from backend race conditions in non-atomic domain_member NVP updates that can orphan companyCards entries.


📋 Changes Overview

File Changes
src/selectors/Card.ts New feedKeysWithAssignedCardsSelector for O(1) lookup
src/libs/CardUtils.ts New isDirectFeed(), feedHasCards() helpers; updated getOriginalCompanyFeeds()
src/libs/CardFeedUtils.ts Updated visibility filtering in multiple functions
src/libs/SearchQueryUtils.ts Threading feedKeysWithCards through query builders
Components (7 files) Wiring feedKeysWithCards via useOnyx
Tests 40+ unit tests added

✅ Strengths

  1. Well-designed three-tier classification system:

    • Commercial feeds (isCustomFeed): Always shown - file-based, no OAuth dependency
    • Direct feeds (isDirectFeed): Shown with oAuthAccountDetails OR assigned cards
    • Gray-zone feeds: Shown only if they have assigned cards
  2. Performance-optimized approach:

    • The feedKeysWithAssignedCardsSelector creates a lightweight Record<string, true> map for O(1) lookups
    • Avoids passing the entire WORKSPACE_CARDS_LIST collection through utility functions
    • Good use of Onyx selectors to minimize re-renders
  3. Comprehensive test coverage:

    • 40+ unit tests covering all feed type classifications
    • Edge cases for OldDot-style keys with spaces
    • Tests for mixed scenarios and card-based fallback logic
  4. Backwards compatible:

    • When feedKeysWithCards is not provided, the functions default to showing all feeds (no breaking changes)
  5. Good documentation:

    • Clear JSDoc comments explaining the visibility rules
    • Well-documented PR description with testing steps

🔍 Concerns / Suggestions

1. Type signature change in isCustomFeed

function isCustomFeed(feed: string | undefined): boolean {
    // ...
}

The type was changed from CardFeedWithNumber | CardFeedWithDomainID | undefined to string | undefined. While this works, it's a loosening of the type. Consider whether this was intentional or if it could mask potential type issues elsewhere.

2. eslint-disable comment added

// eslint-disable-next-line @typescript-eslint/max-params
function getDisplayQueryFiltersForKey(

This function now takes 10 parameters. Consider refactoring to accept an options object instead:

function getDisplayQueryFiltersForKey(options: {
    key: string;
    queryFilter: QueryFilter[];
    cardList: OnyxTypes.CardList | undefined;
    // ... etc
}) {

3. Duplicated filtering logic

The feed visibility filtering logic appears in both getOriginalCompanyFeeds() in CardUtils.ts and getCombinedCardFeedsFromAllFeeds() in CardFeedUtils.ts:

// When we have card data, filter out stale feeds:
// - Direct feeds without oAuthAccountDetails AND no assigned cards
// - "Gray zone" feeds (not commercial, not direct) without assigned cards
if (feedKeysWithCards) {
    if (isDirectFeed(feedName) && !oAuthAccountDetails && !feedHasCards(feedName, domainID, feedKeysWithCards)) {
        continue;
    }
    if (!isCustomFeed(feedName) && !isDirectFeed(feedName) && !feedHasCards(feedName, domainID, feedKeysWithCards)) {
        continue;
    }
}

This is also in CardUtils.ts at lines 495-516. Consider extracting this into a shared helper like shouldShowFeed() to ensure consistency and avoid drift.

4. Missing null checks in selector

const feedKeysWithAssignedCardsSelector = (allWorkspaceCards: OnyxCollection<WorkspaceCardsList>): FeedKeysWithAssignedCards => {
    const result: FeedKeysWithAssignedCards = {};

    for (const [key, cards] of Object.entries(allWorkspaceCards ?? {})) {
        if (!cards) {
            continue;
        }

        const {cardList, ...assignedCards} = cards;
        if (Object.keys(assignedCards).length > 0) {
            const feedKey = key.replace(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, '');
            result[feedKey] = true;
        }
    }

    return result;
};

The destructuring const {cardList, ...assignedCards} = cards; assumes cards is an object with enumerable keys. This looks fine, but worth adding a type guard if cards could be a non-object primitive.

5. Test data consistency

The test fixtures were updated to add oAuthAccountDetails in several test files:

oAuthAccountDetails: {
    [cardFeedAmericaExpressMock]: {accountList: ['CREDIT CARD...1234'], credentials: 'xxxxx', expiration: 1730998958},
    [cardFeedCitiBankMock]: {accountList: ['CREDIT CARD...5678'], credentials: 'xxxxx', expiration: 1730998958},
},

This is good for ensuring tests pass, but make sure these additions don't mask real-world scenarios where oAuthAccountDetails is actually missing.


🧪 Testing Recommendations

  1. Test with actual affected accounts - The PR mentions needing to test with accounts that reported the issue. Ensure this is completed before merging.

  2. Verify search filters - Confirm that the feed dropdowns in search correctly reflect the new visibility rules.

  3. Cache clearing - The author noted "the builds are not clearing cache so its hard to test" - ensure fresh testing is done.


📊 Code Quality

  • ✅ Tests pass with good coverage
  • ✅ TypeScript types properly extended
  • ✅ Code is DRY (selector pattern for reuse)
  • ✅ Reviewer checklist completed by @ShridharGoel
  • ⚠️ Coverage slightly decreased for cardFeedErrors.ts (-1.41%)

🎯 Verdict

Overall: 👍 LGTM with minor suggestions

The PR is well-structured, thoroughly tested, and addresses a real backend data consistency issue. The three-tier approach is clean and the performance optimizations via selectors are appropriate.

Minor improvements to consider:

  1. Extract duplicated filtering logic into a shared helper
  2. Consider refactoring getDisplayQueryFiltersForKey to use an options object instead of 10 parameters
  3. Verify the isCustomFeed type loosening was intentional

Add typeof check to ensure cards value is an object before destructuring,
guarding against unexpected non-object primitives in Onyx collection data.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mountiny mountiny changed the title [WIP] Filter out stale direct feeds missing oAuthAccountDetails Filter out stale direct feeds missing oAuthAccountDetails Feb 12, 2026
"Bushwick",
"BYOC",
"capitalone",
"capitalonecards",
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB 🤔

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.

4 participants