diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index c27aa994af60..755710774d4d 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -442,6 +442,7 @@ function createCorpayBankAccount(fields: ReimbursementAccountForm, policyID: str value: { isLoading: false, isCreateCorpayBankAccount: false, + errors: null, isSuccess: true, }, }, @@ -454,7 +455,6 @@ function createCorpayBankAccount(fields: ReimbursementAccountForm, policyID: str isLoading: false, isCreateCorpayBankAccount: false, isSuccess: false, - errors: getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), }, }, ], diff --git a/src/pages/ReimbursementAccount/NonUSD/BankInfo/BankInfo.tsx b/src/pages/ReimbursementAccount/NonUSD/BankInfo/BankInfo.tsx index a766306cc814..2e841f1e3d96 100644 --- a/src/pages/ReimbursementAccount/NonUSD/BankInfo/BankInfo.tsx +++ b/src/pages/ReimbursementAccount/NonUSD/BankInfo/BankInfo.tsx @@ -51,18 +51,18 @@ function BankInfo({onBackButtonPress, onSubmit, policyID}: BankInfoProps) { }; useEffect(() => { - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (reimbursementAccount?.errors || reimbursementAccount?.isLoading || !reimbursementAccount?.isSuccess) { + if (reimbursementAccount?.isLoading === true || !!reimbursementAccount?.errors) { return; } - if (reimbursementAccount?.isSuccess) { + if (reimbursementAccount?.isSuccess === true) { onSubmit(); - clearReimbursementAccountBankCreation(); } + }, [onSubmit, reimbursementAccount?.errors, reimbursementAccount?.isLoading, reimbursementAccount?.isSuccess]); + useEffect(() => { return () => clearReimbursementAccountBankCreation(); - }, [onSubmit, reimbursementAccount?.errors, reimbursementAccount?.isCreateCorpayBankAccount, reimbursementAccount?.isLoading, reimbursementAccount?.isSuccess]); + }, []); useEffect(() => { if (country === '') {