diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index dc5b7b83aa8e..bcc5d8142470 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -214,7 +214,7 @@ function clearDebitCardFormErrorAndSubmit() { Onyx.set(ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM, { isLoading: false, errors: undefined, - setupComplete: true, + setupComplete: false, }); } diff --git a/src/pages/settings/Wallet/AddDebitCardPage.js b/src/pages/settings/Wallet/AddDebitCardPage.js index 8b8938a9ea42..5b99bd49812c 100644 --- a/src/pages/settings/Wallet/AddDebitCardPage.js +++ b/src/pages/settings/Wallet/AddDebitCardPage.js @@ -46,8 +46,15 @@ function DebitCardPage(props) { const prevFormDataSetupComplete = usePrevious(props.formData.setupComplete); const nameOnCardRef = useRef(null); + /** + * Reset the form values on the mount and unmount so that old errors don't show when this form is displayed again. + */ useEffect(() => { PaymentMethods.clearDebitCardFormErrorAndSubmit(); + + return () => { + PaymentMethods.clearDebitCardFormErrorAndSubmit(); + }; }, []); useEffect(() => { @@ -56,10 +63,6 @@ function DebitCardPage(props) { } PaymentMethods.continueSetup(); - - return () => { - PaymentMethods.clearDebitCardFormErrorAndSubmit(); - }; }, [prevFormDataSetupComplete, props.formData.setupComplete]); /**