-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix: get all the cards from different feeds #52612
Merged
mountiny
merged 5 commits into
Expensify:main
from
callstack-internal:fix/51881-show-cards-from-all-feeds
Jan 12, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
012840d
fix: get all the cards from different feeds
koko57 eb859fc
fix: remove unnecessary dep
koko57 c2d9921
fix: resolve conflicts
koko57 34bec4c
fix: eslint
koko57 e0120b5
fix: check if there are cards assigned to display cards section
koko57 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 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 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 |
---|---|---|
|
@@ -62,10 +62,7 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM | |
const {formatPhoneNumber, translate} = useLocalize(); | ||
const StyleUtils = useStyleUtils(); | ||
const currentUserPersonalDetails = useCurrentUserPersonalDetails(); | ||
const [cards] = useOnyx(`${ONYXKEYS.CARD_LIST}`); | ||
const [expensifyCards] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`); | ||
const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`); | ||
const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`); | ||
|
||
const [isRemoveMemberConfirmModalVisible, setIsRemoveMemberConfirmModalVisible] = useState(false); | ||
const [isRoleSelectionModalVisible, setIsRoleSelectionModalVisible] = useState(false); | ||
|
@@ -84,29 +81,20 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM | |
const ownerDetails = personalDetails?.[policy?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID] ?? ({} as PersonalDetails); | ||
const policyOwnerDisplayName = formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(ownerDetails)) ?? policy?.owner ?? ''; | ||
const hasMultipleFeeds = Object.values(CardUtils.getCompanyFeeds(cardFeeds)).filter((feed) => !feed.pending).length > 0; | ||
const paymentAccountID = cardSettings?.paymentBankAccountID ?? CONST.DEFAULT_NUMBER_ID; | ||
|
||
const workspaceCards = CardUtils.getAllCardsForWorkspace(workspaceAccountID); | ||
const hasWorkspaceCardsAssigned = !!workspaceCards && !!Object.values(workspaceCards).length; | ||
|
||
useEffect(() => { | ||
CompanyCards.openPolicyCompanyCardsPage(policyID, workspaceAccountID); | ||
}, [policyID, workspaceAccountID]); | ||
|
||
const memberCards = useMemo(() => { | ||
if (!cards && !expensifyCards) { | ||
if (!workspaceCards) { | ||
return []; | ||
} | ||
// For admin Expensify Cards can also appear in the cards list, so we need to remove duplicates | ||
const allCards = [...Object.values(cards ?? {}), ...Object.values(expensifyCards ?? {})]; | ||
const cardIDs = new Set(); | ||
const uniqueObjects = allCards.filter((obj) => { | ||
if (cardIDs.has(obj.cardID)) { | ||
return false; | ||
} | ||
cardIDs.add(obj.cardID); | ||
return true; | ||
}); | ||
|
||
return Object.values(uniqueObjects ?? {}).filter((card) => card.accountID === accountID && workspaceAccountID.toString() === card.fundID); | ||
}, [accountID, workspaceAccountID, cards, expensifyCards]); | ||
return Object.values(workspaceCards ?? {}).filter((card) => card.accountID === accountID); | ||
}, [accountID, workspaceCards]); | ||
|
||
const confirmModalPrompt = useMemo(() => { | ||
const isApprover = Member.isApprover(policy, accountID); | ||
|
@@ -220,7 +208,7 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM | |
return <NotFoundPage />; | ||
} | ||
|
||
const shouldShowCardsSection = (!!policy?.areExpensifyCardsEnabled && !!paymentAccountID) || (!!policy?.areCompanyCardsEnabled && hasMultipleFeeds); | ||
const shouldShowCardsSection = hasWorkspaceCardsAssigned && (!!policy?.areExpensifyCardsEnabled || !!policy?.areCompanyCardsEnabled); | ||
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. We should use the old condition here. this new change caused #56372 |
||
|
||
return ( | ||
<AccessOrNotFoundWrapper | ||
|
@@ -316,7 +304,7 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM | |
{translate('walletPage.assignedCards')} | ||
</Text> | ||
</View> | ||
{(memberCards as MemberCard[]).map((memberCard) => { | ||
{memberCards.map((memberCard) => { | ||
const isCardDeleted = memberCard.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; | ||
return ( | ||
<OfflineWithFeedback | ||
|
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.
Can you please add a comment that in case of direct feeds, the list of unassigned cards yet is returned in the cardList property in the collection?