Repository navigation
Filter out stale direct feeds missing oAuthAccountDetails #82056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e2bf740
Filter out stale direct feeds missing oAuthAccountDetails
mountiny bcb9dd4
Optimize stale direct feed filtering with lightweight selector
mountiny d2a32c6
Merge main
mountiny 4a86e12
Sync sumodule
mountiny 8fc00ab
Merge remote-tracking branch 'origin/main' into vit-directFeedFix
mountiny e18f748
Use CONST.DEFAULT_NUMBER_ID instead of 0 for domainID default
mountiny 03bfc29
Filter out gray-zone feeds without assigned cards
mountiny 2135796
Fix spellcheck and TypeScript CI failures
mountiny 16ed807
Add ADHOC label to company cards header for build verification
mountiny f4d82b2
Merge branch 'main' into vit-directFeedFix
mountiny 15fa8f2
Revert the Adhoc from testing
mountiny a1bdf7a
Resolve merge conflict
mountiny d8f6b32
Merge main into vit-directFeedFix
mountiny 92496e9
Merge main into vit-directFeedFix
mountiny 8cab354
Merge remote-tracking branch 'origin/main' into vit-directFeedFix
mountiny 84f35b6
Align Mobile-Expensify submodule with main
mountiny 9327750
Add type guard in feedKeysWithAssignedCardsSelector
mountiny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import type {FeedKeysWithAssignedCards} from '@selectors/Card'; | ||
| import type {OnyxCollection} from 'react-native-onyx'; | ||
| import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; | ||
| import type {AdditionalCardProps} from '@components/SelectionListWithSections/Search/CardListItem'; | ||
|
|
@@ -9,6 +10,7 @@ import type {Card, CardFeeds, CardList, PersonalDetailsList, Policy, WorkspaceCa | |
| import type {CardFeedsStatus, CardFeedsStatusByDomainID, CardFeedWithNumber, CombinedCardFeed} from '@src/types/onyx/CardFeeds'; | ||
| import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import { | ||
| feedHasCards, | ||
| getBankName, | ||
| getCardFeedIcon, | ||
| getCardFeedWithDomainID, | ||
|
|
@@ -19,6 +21,8 @@ import { | |
| isCard, | ||
| isCardClosed, | ||
| isCardHiddenFromSearch, | ||
| isCustomFeed, | ||
| isDirectFeed, | ||
| } from './CardUtils'; | ||
| import type {CompanyCardFeedIcons} from './CardUtils'; | ||
| import {getDescriptionForPolicyDomainCard} from './PolicyUtils'; | ||
|
|
@@ -435,7 +439,12 @@ const generateSelectedCards = ( | |
| * | ||
| * The `allCards` parameter is only used to determine if we should add the "Expensify Card" feeds. | ||
| */ | ||
| function getCardFeedsForDisplay(allCardFeeds: OnyxCollection<CardFeeds>, allCards: CardList | undefined, translate: LocalizedTranslate): CardFeedsForDisplay { | ||
| function getCardFeedsForDisplay( | ||
| allCardFeeds: OnyxCollection<CardFeeds>, | ||
| allCards: CardList | undefined, | ||
| translate: LocalizedTranslate, | ||
| feedKeysWithCards?: FeedKeysWithAssignedCards, | ||
| ): CardFeedsForDisplay { | ||
| const cardFeedsForDisplay = {} as CardFeedsForDisplay; | ||
|
|
||
| for (const [domainKey, cardFeeds] of Object.entries(allCardFeeds ?? {})) { | ||
|
|
@@ -445,7 +454,7 @@ function getCardFeedsForDisplay(allCardFeeds: OnyxCollection<CardFeeds>, allCard | |
| continue; | ||
| } | ||
|
|
||
| for (const key of Object.keys(getOriginalCompanyFeeds(cardFeeds))) { | ||
| for (const key of Object.keys(getOriginalCompanyFeeds(cardFeeds, feedKeysWithCards, Number(fundID)))) { | ||
| const feed = key as CardFeedWithNumber; | ||
| const id = `${fundID}_${feed}`; | ||
|
|
||
|
|
@@ -489,7 +498,11 @@ function getCardFeedsForDisplay(allCardFeeds: OnyxCollection<CardFeeds>, allCard | |
| * | ||
| * Note: "Expensify Card" feeds are not included. | ||
| */ | ||
| function getCardFeedsForDisplayPerPolicy(allCardFeeds: OnyxCollection<CardFeeds>, translate: LocalizedTranslate): Record<string, CardFeedForDisplay[]> { | ||
| function getCardFeedsForDisplayPerPolicy( | ||
| allCardFeeds: OnyxCollection<CardFeeds>, | ||
| translate: LocalizedTranslate, | ||
| feedKeysWithCards?: FeedKeysWithAssignedCards, | ||
| ): Record<string, CardFeedForDisplay[]> { | ||
| const cardFeedsForDisplayPerPolicy = {} as Record<string, CardFeedForDisplay[]>; | ||
|
|
||
| for (const [domainKey, cardFeeds] of Object.entries(allCardFeeds ?? {})) { | ||
|
|
@@ -499,7 +512,7 @@ function getCardFeedsForDisplayPerPolicy(allCardFeeds: OnyxCollection<CardFeeds> | |
| continue; | ||
| } | ||
|
|
||
| for (const [key, feedData] of Object.entries(getOriginalCompanyFeeds(cardFeeds))) { | ||
| for (const [key, feedData] of Object.entries(getOriginalCompanyFeeds(cardFeeds, feedKeysWithCards, Number(fundID)))) { | ||
| const preferredPolicy = feedData && 'preferredPolicy' in feedData ? (feedData.preferredPolicy ?? '') : ''; | ||
| const feed = key as CardFeedWithNumber; | ||
| const id = `${fundID}_${feed}`; | ||
|
|
@@ -531,7 +544,11 @@ function getWorkspaceCardFeedsStatus(allFeeds: OnyxCollection<CardFeeds> | undef | |
| }, {} as CardFeedsStatusByDomainID); | ||
| } | ||
|
|
||
| function getCombinedCardFeedsFromAllFeeds(allFeeds: OnyxCollection<CardFeeds> | undefined, includeFeedPredicate?: (feed: CombinedCardFeed) => boolean): CombinedCardFeeds { | ||
| function getCombinedCardFeedsFromAllFeeds( | ||
| allFeeds: OnyxCollection<CardFeeds> | undefined, | ||
| includeFeedPredicate?: (feed: CombinedCardFeed) => boolean, | ||
| feedKeysWithCards?: FeedKeysWithAssignedCards, | ||
| ): CombinedCardFeeds { | ||
| return Object.entries(allFeeds ?? {}).reduce<CombinedCardFeeds>((acc, [onyxKey, feeds]) => { | ||
| const domainID = Number(onyxKey.split('_').at(-1)); | ||
|
|
||
|
|
@@ -552,6 +569,18 @@ function getCombinedCardFeedsFromAllFeeds(allFeeds: OnyxCollection<CardFeeds> | | |
| continue; | ||
| } | ||
|
|
||
| // 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)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a CSV feed, unassigned cards are not loaded until the feed is selected, which we couldn't do because we were not displaying it. This causes this issue: #86814 |
||
| continue; | ||
| } | ||
| } | ||
|
|
||
| const combinedCardFeed: CombinedCardFeed = { | ||
| ...feedSettings, | ||
| ...oAuthAccountDetails, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could skip it in place, I can do it in a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#82390