From 963b00b6987e1a72a460984188630255a58d81c7 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 21 Aug 2024 13:06:56 +0200 Subject: [PATCH 1/3] fix: navigate back to expensify card page after issuing, show only cards assigned to the member in details --- .../WorkspaceExpensifyCardPageEmptyState.tsx | 2 +- .../expensifyCard/issueNew/ConfirmationStep.tsx | 3 ++- .../members/WorkspaceMemberDetailsPage.tsx | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx index 15ad69b3ba13..4d4a2927d194 100644 --- a/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx +++ b/src/pages/workspace/expensifyCard/WorkspaceExpensifyCardPageEmptyState.tsx @@ -50,7 +50,7 @@ function WorkspaceExpensifyCardPageEmptyState({route, policy}: WorkspaceExpensif const eligibleBankAccounts = CardUtils.getEligibleBankAccountsForCard(bankAccountList ?? {}); const reimbursementAccountStatus = reimbursementAccount?.achData?.state ?? ''; - const isSetupUnfinished = isEmptyObject(bankAccountList) && reimbursementAccountStatus !== CONST.BANK_ACCOUNT.STATE.OPEN; + const isSetupUnfinished = isEmptyObject(bankAccountList) && reimbursementAccountStatus && reimbursementAccountStatus !== CONST.BANK_ACCOUNT.STATE.OPEN; const startFlow = useCallback(() => { if (!eligibleBankAccounts.length || isSetupUnfinished) { diff --git a/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx b/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx index 75758e84e62c..aed246227d7d 100644 --- a/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx +++ b/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx @@ -18,6 +18,7 @@ import Navigation from '@navigation/Navigation'; import * as Card from '@userActions/Card'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import type {IssueNewCardStep} from '@src/types/onyx/Card'; type ConfirmationStepProps = { @@ -36,7 +37,7 @@ function ConfirmationStep({policyID}: ConfirmationStepProps) { const submit = () => { Card.issueExpensifyCard(policyID, CONST.COUNTRY.US, data); - Navigation.goBack(); + Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID ?? '-1')); Card.clearIssueNewCardFlow(); }; diff --git a/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx b/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx index 2742033430ba..60216745c11e 100644 --- a/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx +++ b/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx @@ -75,12 +75,22 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM const ownerDetails = personalDetails?.[policy?.ownerAccountID ?? -1] ?? ({} as PersonalDetails); const policyOwnerDisplayName = ownerDetails.displayName ?? policy?.owner ?? ''; + const memberCards = useMemo(() => { + if (!cardsList) { + return []; + } + return Object.values(cardsList).filter((card) => card.accountID === accountID); + }, [cardsList, accountID]); + const confirmModalPrompt = useMemo(() => { const isApprover = Member.isApprover(policy, accountID); if (!isApprover) { return translate('workspace.people.removeMemberPrompt', {memberName: displayName}); } - return translate('workspace.people.removeMembersWarningPrompt', {memberName: displayName, ownerName: policyOwnerDisplayName}); + return translate('workspace.people.removeMembersWarningPrompt', { + memberName: displayName, + ownerName: policyOwnerDisplayName, + }); }, [accountID, policy, displayName, policyOwnerDisplayName, translate]); const roleItems: ListItemType[] = useMemo( @@ -259,7 +269,7 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM {translate('walletPage.assignedCards')} - {Object.values(cardsList ?? {}).map((card) => ( + {memberCards.map((card) => ( Date: Wed, 21 Aug 2024 15:38:47 +0200 Subject: [PATCH 2/3] fix: return to proper page from issuenew card flow --- src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx b/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx index 3190c4ba295c..de7fddefa9dc 100644 --- a/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx +++ b/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx @@ -57,7 +57,7 @@ function AssigneeStep({policy}: AssigneeStepProps) { Card.setIssueNewCardStepAndData({step: CONST.EXPENSIFY_CARD.STEP.CONFIRMATION, isEditing: false}); return; } - Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policy?.id ?? '-1')); + Navigation.goBack(); Card.clearIssueNewCardFlow(); }; From 7a3d786d9ad3109e81dd36d72234f400e6f0b4a1 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 22 Aug 2024 10:18:54 +0200 Subject: [PATCH 3/3] fix: lint --- src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx b/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx index de7fddefa9dc..042e93ae2fae 100644 --- a/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx +++ b/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx @@ -22,7 +22,6 @@ import Navigation from '@navigation/Navigation'; import * as Card from '@userActions/Card'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; const MINIMUM_MEMBER_TO_SHOW_SEARCH = 8;