From ede313c65c7da4bf361de60f317e0739ab068b0d Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Tue, 10 Dec 2024 17:03:50 +0100 Subject: [PATCH 1/2] fix: clear previous data from Expensify Card flow --- src/libs/actions/Card.ts | 4 ++-- .../expensifyCard/issueNew/AssigneeStep.tsx | 1 - .../expensifyCard/issueNew/ConfirmationStep.tsx | 12 ++---------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index 1c60d49e9170..c8dce813c895 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -392,8 +392,8 @@ function clearIssueNewCardFlow() { }); } -function clearIssueNewCardError(issueNewCard: IssueNewCardFlowData) { - Onyx.set(ONYXKEYS.ISSUE_NEW_EXPENSIFY_CARD, {...issueNewCard, errors: null}); +function clearIssueNewCardError() { + Onyx.merge(ONYXKEYS.ISSUE_NEW_EXPENSIFY_CARD, {errors: null}); } function updateExpensifyCardLimit(workspaceAccountID: number, cardID: number, newLimit: number, newAvailableSpend: number, oldLimit?: number, oldAvailableSpend?: number) { diff --git a/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx b/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx index 769532e49351..a1328645d447 100644 --- a/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx +++ b/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx @@ -62,7 +62,6 @@ function AssigneeStep({policy}: AssigneeStepProps) { return; } Navigation.goBack(); - Card.clearIssueNewCardFlow(); }; const shouldShowSearchInput = policy?.employeeList && Object.keys(policy.employeeList).length >= MINIMUM_MEMBER_TO_SHOW_SEARCH; diff --git a/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx b/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx index c65ae8957dbe..8521da690fe2 100644 --- a/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx +++ b/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx @@ -58,7 +58,6 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) { return; } Navigation.navigate(backTo ?? ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID ?? '-1')); - Card.clearIssueNewCardFlow(); }, [backTo, policyID, isSuccessful]); const submit = (validateCode: string) => { @@ -142,15 +141,8 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) { sendValidateCode={() => User.requestValidateCodeAction()} validateError={validateError} hasMagicCodeBeenSent={validateCodeSent} - clearError={() => { - Card.clearIssueNewCardError(issueNewCard); - }} - onClose={() => { - if (validateError) { - Card.clearIssueNewCardError(issueNewCard); - } - setIsValidateCodeActionModalVisible(false); - }} + clearError={() => Card.clearIssueNewCardError()} + onClose={() => setIsValidateCodeActionModalVisible(false)} isVisible={isValidateCodeActionModalVisible} title={translate('cardPage.validateCardTitle')} descriptionPrimary={translate('cardPage.enterMagicCode', {contactMethod: account?.primaryLogin ?? ''})} From 2a8952de6fc7cc4a0d0b406ae3a044136df2e9de Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 12 Dec 2024 12:27:25 +0100 Subject: [PATCH 2/2] fix: revert removing clearIssueNewCardFlow from Confirmation step and assignee step, remove the one in the IssueNewCardPage --- src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx | 1 + .../workspace/expensifyCard/issueNew/ConfirmationStep.tsx | 1 + .../workspace/expensifyCard/issueNew/IssueNewCardPage.tsx | 6 ------ 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx b/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx index a1328645d447..769532e49351 100644 --- a/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx +++ b/src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx @@ -62,6 +62,7 @@ function AssigneeStep({policy}: AssigneeStepProps) { return; } Navigation.goBack(); + Card.clearIssueNewCardFlow(); }; const shouldShowSearchInput = policy?.employeeList && Object.keys(policy.employeeList).length >= MINIMUM_MEMBER_TO_SHOW_SEARCH; diff --git a/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx b/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx index 8521da690fe2..e0db6935b0a1 100644 --- a/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx +++ b/src/pages/workspace/expensifyCard/issueNew/ConfirmationStep.tsx @@ -58,6 +58,7 @@ function ConfirmationStep({policyID, backTo}: ConfirmationStepProps) { return; } Navigation.navigate(backTo ?? ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID ?? '-1')); + Card.clearIssueNewCardFlow(); }, [backTo, policyID, isSuccessful]); const submit = (validateCode: string) => { diff --git a/src/pages/workspace/expensifyCard/issueNew/IssueNewCardPage.tsx b/src/pages/workspace/expensifyCard/issueNew/IssueNewCardPage.tsx index 2c9fbd1d193e..27653df9f9b0 100644 --- a/src/pages/workspace/expensifyCard/issueNew/IssueNewCardPage.tsx +++ b/src/pages/workspace/expensifyCard/issueNew/IssueNewCardPage.tsx @@ -34,12 +34,6 @@ function IssueNewCardPage({policy, route}: IssueNewCardPageProps) { Card.startIssueNewCardFlow(policyID); }, [policyID]); - useEffect(() => { - return () => { - Card.clearIssueNewCardFlow(); - }; - }, []); - const getCurrentStep = () => { switch (currentStep) { case CONST.EXPENSIFY_CARD.STEP.ASSIGNEE: