Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {getCurrencySymbol} from '@libs/CurrencyUtils';
import {getLatestErrorMessage} from '@libs/ErrorUtils';
import type CustomSubStepProps from '@pages/settings/Wallet/InternationalDepositAccount/types';
import {clearReimbursementAccountBankCreation, createCorpayBankAccountForWalletFlow} from '@userActions/BankAccounts';
import {clearReimbursementAccountBankCreation, createCorpayBankAccountForWalletFlow, hideBankAccountErrors} from '@userActions/BankAccounts';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -76,6 +76,17 @@ function Confirmation({onNext, onMove, formValues, fieldsMap}: CustomSubStepProp
}
}, [reimbursementAccount?.isLoading, reimbursementAccount?.isSuccess, reimbursementAccount?.errors, onNext]);

// We want to clear errors every time we leave this page.
// Therefore, we use useEffect, which clears errors when unmounted.
// This is necessary so that when we close the BA flow or move on to another step, the error is cleared.
// Additionally, we add error clearing to useEffect itself so that errors are cleared if this page opens after reloading.
useEffect(() => {
hideBankAccountErrors();
return () => {
hideBankAccountErrors();
};
Comment on lines +84 to +87

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if you reload, the unmount function does get called. I think only one of these is necessary here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's not actually the case. I recorded a video with two cases where the error is not cleared if it is not cleared before entering the page, because useEffect on unmount is not called before reloading/changing the page URL.

-.-2025-09-01-.-10.14.30.mp4

}, []);

const summaryItems: MenuItemProps[] = [
{
description: translate('common.country'),
Expand Down