Skip to content

Commit d2a0b55

Browse files
committed
fix error message
1 parent e77394c commit d2a0b55

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/libs/actions/BankAccounts.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import ROUTES from '@src/ROUTES';
2929
import type {Route} from '@src/ROUTES';
3030
import type {InternationalBankAccountForm, PersonalBankAccountForm} from '@src/types/form';
3131
import type {ACHContractStepProps, BeneficialOwnersStepProps, CompanyStepProps, ReimbursementAccountForm, RequestorStepProps} from '@src/types/form/ReimbursementAccountForm';
32-
import type {BankAccountList, LastPaymentMethod, LastPaymentMethodType} from '@src/types/onyx';
32+
import type {LastPaymentMethod, LastPaymentMethodType, PersonalBankAccount} from '@src/types/onyx';
3333
import type PlaidBankAccount from '@src/types/onyx/PlaidBankAccount';
3434
import type {BankAccountStep, ReimbursementAccountStep, ReimbursementAccountSubStep} from '@src/types/onyx/ReimbursementAccount';
3535
import type {OnyxData} from '@src/types/onyx/Request';
@@ -52,13 +52,6 @@ export {openOnfidoFlow, answerQuestionsForWallet, verifyIdentity, acceptWalletTe
5252

5353
type AccountFormValues = typeof ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM | typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM;
5454

55-
let bankAccountList: OnyxEntry<BankAccountList>;
56-
57-
Onyx.connect({
58-
key: ONYXKEYS.BANK_ACCOUNT_LIST,
59-
callback: (value) => (bankAccountList = value),
60-
});
61-
6255
function clearPlaid(): Promise<void | void[]> {
6356
Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, '');
6457
Onyx.set(ONYXKEYS.PLAID_CURRENT_EVENT, null);
@@ -336,9 +329,8 @@ function addPersonalBankAccount(account: PlaidBankAccount, policyID?: string, so
336329
API.write(WRITE_COMMANDS.ADD_PERSONAL_BANK_ACCOUNT, parameters, onyxData);
337330
}
338331

339-
function deletePaymentBankAccount(bankAccountID: number, lastUsedPaymentMethods?: LastPaymentMethod) {
332+
function deletePaymentBankAccount(bankAccountID: number, lastUsedPaymentMethods?: LastPaymentMethod, bankAccount?: OnyxEntry<PersonalBankAccount>) {
340333
const parameters: DeletePaymentBankAccountParams = {bankAccountID};
341-
const bankAccount = bankAccountList ? bankAccountList[bankAccountID] : undefined;
342334

343335
const bankAccountFailureData = {
344336
...bankAccount,

src/pages/settings/Wallet/WalletPage/WalletPage.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,19 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) {
295295
const bankAccountID = paymentMethod.selectedPaymentMethod.bankAccountID;
296296
const fundID = paymentMethod.selectedPaymentMethod.fundID;
297297
if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && bankAccountID) {
298-
deletePaymentBankAccount(bankAccountID, lastUsedPaymentMethods);
298+
const bankAccount = bankAccountList?.[paymentMethod.methodID] ?? {};
299+
deletePaymentBankAccount(bankAccountID, lastUsedPaymentMethods, bankAccount);
299300
} else if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD && fundID) {
300301
deletePaymentCard(fundID);
301302
}
302-
}, [paymentMethod.selectedPaymentMethod.bankAccountID, paymentMethod.selectedPaymentMethod.fundID, paymentMethod.selectedPaymentMethodType, lastUsedPaymentMethods]);
303+
}, [
304+
paymentMethod.selectedPaymentMethod.bankAccountID,
305+
paymentMethod.selectedPaymentMethod.fundID,
306+
paymentMethod.selectedPaymentMethodType,
307+
paymentMethod.methodID,
308+
bankAccountList,
309+
lastUsedPaymentMethods,
310+
]);
303311

304312
/**
305313
* Navigate to the appropriate page after completing the KYC flow, depending on what initiated it

0 commit comments

Comments
 (0)