From 03b1ed55cb89c684dd4e8ecfa847c5c19ae5ea48 Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 7 Nov 2025 00:21:30 +0700 Subject: [PATCH 1/9] fix: default badge not reassigned when deleting the top default payment --- .../settings/Wallet/WalletPage/WalletPage.tsx | 41 ++++++++++++++++++- src/types/onyx/AccountData.ts | 3 ++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx index 195d67713156..84a4f4e67ead 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx @@ -263,6 +263,39 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { const deletePaymentMethod = useCallback(() => { const bankAccountID = paymentMethod.selectedPaymentMethod.bankAccountID; const fundID = paymentMethod.selectedPaymentMethod.fundID; + + if (paymentMethod.isSelectedPaymentMethodDefault) { + const paymentCardList = fundList ?? {}; + const allPaymentMethods = formatPaymentMethods(bankAccountList ?? {}, paymentCardList, styles, translate); + + const remainingPaymentMethods = allPaymentMethods + .filter((method) => { + if (method.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && method.accountData?.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS) { + return false; + } + + if (method.methodID === paymentMethod.methodID) { + return false; + } + + return true; + }) + .sort((a, b) => { + const aCreated = a.accountData?.created ?? ''; + const bCreated = b.accountData?.created ?? ''; + if (!aCreated) return 1; + if (!bCreated) return -1; + return new Date(bCreated).getTime() - new Date(aCreated).getTime(); + }); + + if (remainingPaymentMethods.length > 0) { + const newDefaultMethod = remainingPaymentMethods[0]; + const newBankAccountID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod.accountData?.bankAccountID ?? 0) : 0; + const newFundID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD ? (newDefaultMethod.accountData?.fundID ?? 0) : 0; + makeDefaultPaymentMethodPaymentMethods(newBankAccountID, newFundID); + } + } + if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && bankAccountID) { const bankAccount = bankAccountList?.[paymentMethod.methodID] ?? {}; deletePaymentBankAccount(bankAccountID, lastUsedPaymentMethods, bankAccount); @@ -273,9 +306,14 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { paymentMethod.selectedPaymentMethod.bankAccountID, paymentMethod.selectedPaymentMethod.fundID, paymentMethod.selectedPaymentMethodType, - lastUsedPaymentMethods, + paymentMethod.isSelectedPaymentMethodDefault, paymentMethod.methodID, + lastUsedPaymentMethods, bankAccountList, + fundList, + makeDefaultPaymentMethodPaymentMethods, + styles, + translate, ]); /** @@ -384,7 +422,6 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { ); } - return ( Date: Sat, 15 Nov 2025 23:49:10 +0800 Subject: [PATCH 2/9] fix: add the optimistic data for the delete default payment bank account --- src/libs/actions/BankAccounts.ts | 14 +++++++++++++- src/libs/actions/PaymentMethods.ts | 1 + .../settings/Wallet/WalletPage/WalletPage.tsx | 19 +++++++++++++------ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 6c135097e9e5..9f4183056c65 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -35,6 +35,7 @@ import type {BankAccountList, LastPaymentMethod, LastPaymentMethodType, Personal import type PlaidBankAccount from '@src/types/onyx/PlaidBankAccount'; import type {BankAccountStep, ReimbursementAccountStep, ReimbursementAccountSubStep} from '@src/types/onyx/ReimbursementAccount'; import type {OnyxData} from '@src/types/onyx/Request'; +import {getMakeDefaultPaymentOnyxData} from './PaymentMethods'; import {setBankAccountSubStep} from './ReimbursementAccount'; export { @@ -367,7 +368,13 @@ function addPersonalBankAccount(account: PlaidBankAccount, policyID?: string, so API.write(WRITE_COMMANDS.ADD_PERSONAL_BANK_ACCOUNT, parameters, onyxData); } -function deletePaymentBankAccount(bankAccountID: number, lastUsedPaymentMethods?: LastPaymentMethod, bankAccount?: OnyxEntry) { +function deletePaymentBankAccount( + bankAccountID: number, + lastUsedPaymentMethods?: LastPaymentMethod, + bankAccount?: OnyxEntry, + newBankAccountID?: number, + newFundID?: number, +) { const parameters: DeletePaymentBankAccountParams = {bankAccountID}; const bankAccountFailureData = { @@ -408,6 +415,11 @@ function deletePaymentBankAccount(bankAccountID: number, lastUsedPaymentMethods? ], }; + if (newBankAccountID && newFundID) { + const newDefaultPaymentMethodOnyxData = getMakeDefaultPaymentOnyxData(newBankAccountID, newFundID); + onyxData.optimisticData?.push(...newDefaultPaymentMethodOnyxData); + } + Object.keys(lastUsedPaymentMethods ?? {}).forEach((paymentMethodID) => { const lastUsedPaymentMethod = lastUsedPaymentMethods?.[paymentMethodID] as LastPaymentMethodType; diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index 4aae775d0720..fa8564919dae 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -573,6 +573,7 @@ export { addPaymentCard, getPaymentMethods, makeDefaultPaymentMethod, + getMakeDefaultPaymentOnyxData, continueSetup, addSubscriptionPaymentCard, clearPaymentCardFormErrorAndSubmit, diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx index 84a4f4e67ead..dbbebbe180e2 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx @@ -263,7 +263,8 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { const deletePaymentMethod = useCallback(() => { const bankAccountID = paymentMethod.selectedPaymentMethod.bankAccountID; const fundID = paymentMethod.selectedPaymentMethod.fundID; - + let newBankAccountID; + let newFundID; if (paymentMethod.isSelectedPaymentMethodDefault) { const paymentCardList = fundList ?? {}; const allPaymentMethods = formatPaymentMethods(bankAccountList ?? {}, paymentCardList, styles, translate); @@ -274,6 +275,14 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { return false; } + if (method.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && method.accountData?.state !== CONST.BANK_ACCOUNT.STATE.OPEN) { + return false; + } + + if (method.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { + return false; + } + if (method.methodID === paymentMethod.methodID) { return false; } @@ -290,15 +299,14 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { if (remainingPaymentMethods.length > 0) { const newDefaultMethod = remainingPaymentMethods[0]; - const newBankAccountID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod.accountData?.bankAccountID ?? 0) : 0; - const newFundID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD ? (newDefaultMethod.accountData?.fundID ?? 0) : 0; - makeDefaultPaymentMethodPaymentMethods(newBankAccountID, newFundID); + newBankAccountID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod.accountData?.bankAccountID ?? 0) : 0; + newFundID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD ? (newDefaultMethod.accountData?.fundID ?? 0) : 0; } } if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && bankAccountID) { const bankAccount = bankAccountList?.[paymentMethod.methodID] ?? {}; - deletePaymentBankAccount(bankAccountID, lastUsedPaymentMethods, bankAccount); + deletePaymentBankAccount(bankAccountID, lastUsedPaymentMethods, bankAccount, newBankAccountID, newFundID); } else if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD && fundID) { deletePaymentCard(fundID); } @@ -311,7 +319,6 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { lastUsedPaymentMethods, bankAccountList, fundList, - makeDefaultPaymentMethodPaymentMethods, styles, translate, ]); From 489af0c21ac802650371f9d7d0e36df2210e63c6 Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 19 Nov 2025 18:08:17 +0700 Subject: [PATCH 3/9] fix lint --- src/libs/actions/BankAccounts.ts | 2 +- src/pages/settings/Wallet/WalletPage/WalletPage.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 04dad926e6e8..5b4ad8821643 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -415,7 +415,7 @@ function deletePaymentBankAccount( ], }; - if (newBankAccountID && newFundID) { + if (newBankAccountID && !!newFundID) { const newDefaultPaymentMethodOnyxData = getMakeDefaultPaymentOnyxData(newBankAccountID, newFundID); onyxData.optimisticData?.push(...newDefaultPaymentMethodOnyxData); } diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx index dbbebbe180e2..5c3df8c0929a 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.tsx +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.tsx @@ -316,11 +316,11 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) { paymentMethod.selectedPaymentMethodType, paymentMethod.isSelectedPaymentMethodDefault, paymentMethod.methodID, - lastUsedPaymentMethods, - bankAccountList, fundList, + bankAccountList, styles, translate, + lastUsedPaymentMethods, ]); /** From 5c47589d62c434ae8b82be34632885f1bce0ebe8 Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 19 Dec 2025 13:52:50 +0700 Subject: [PATCH 4/9] fix lint --- src/pages/settings/Wallet/WalletPage/index.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pages/settings/Wallet/WalletPage/index.tsx b/src/pages/settings/Wallet/WalletPage/index.tsx index b0baeeb45309..4d98b394a54b 100644 --- a/src/pages/settings/Wallet/WalletPage/index.tsx +++ b/src/pages/settings/Wallet/WalletPage/index.tsx @@ -227,15 +227,20 @@ function WalletPage() { .sort((a, b) => { const aCreated = a.accountData?.created ?? ''; const bCreated = b.accountData?.created ?? ''; - if (!aCreated) return 1; - if (!bCreated) return -1; + if (!aCreated) { + return 1; + } + if (!bCreated) { + return -1; + } return new Date(bCreated).getTime() - new Date(aCreated).getTime(); }); if (remainingPaymentMethods.length > 0) { - const newDefaultMethod = remainingPaymentMethods[0]; - newBankAccountID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod.accountData?.bankAccountID ?? 0) : 0; - newFundID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD ? (newDefaultMethod.accountData?.fundID ?? 0) : 0; + const newDefaultMethod = remainingPaymentMethods.at(0); + newBankAccountID = + newDefaultMethod.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod.accountData?.bankAccountID ?? CONST.DEFAULT_NUMBER_ID) : 0; + newFundID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD ? (newDefaultMethod.accountData?.fundID ?? CONST.DEFAULT_NUMBER_ID) : 0; } } From bea81e2f86b5de23b0696270f301385eca8916cf Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 19 Dec 2025 14:01:43 +0700 Subject: [PATCH 5/9] fix lint --- src/pages/settings/Wallet/WalletPage/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/settings/Wallet/WalletPage/index.tsx b/src/pages/settings/Wallet/WalletPage/index.tsx index 4d98b394a54b..18b8fb588148 100644 --- a/src/pages/settings/Wallet/WalletPage/index.tsx +++ b/src/pages/settings/Wallet/WalletPage/index.tsx @@ -198,8 +198,8 @@ function WalletPage() { const deletePaymentMethod = useCallback(() => { const bankAccountID = paymentMethod.selectedPaymentMethod.bankAccountID; const fundID = paymentMethod.selectedPaymentMethod.fundID; - let newBankAccountID; - let newFundID; + let newBankAccountID: number | undefined; + let newFundID: number | undefined; if (paymentMethod.isSelectedPaymentMethodDefault) { const paymentCardList = fundList ?? {}; const allPaymentMethods = formatPaymentMethods(bankAccountList ?? {}, paymentCardList, styles, translate); @@ -239,8 +239,8 @@ function WalletPage() { if (remainingPaymentMethods.length > 0) { const newDefaultMethod = remainingPaymentMethods.at(0); newBankAccountID = - newDefaultMethod.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod.accountData?.bankAccountID ?? CONST.DEFAULT_NUMBER_ID) : 0; - newFundID = newDefaultMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD ? (newDefaultMethod.accountData?.fundID ?? CONST.DEFAULT_NUMBER_ID) : 0; + newDefaultMethod?.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod?.accountData?.bankAccountID ?? CONST.DEFAULT_NUMBER_ID) : 0; + newFundID = newDefaultMethod?.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD ? (newDefaultMethod?.accountData?.fundID ?? CONST.DEFAULT_NUMBER_ID) : 0; } } From eac0750b1da48fc8e671a845bb042f3dfbe8ddf2 Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 22 Dec 2025 16:00:43 +0700 Subject: [PATCH 6/9] fix lint --- src/pages/settings/Wallet/WalletPage/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/settings/Wallet/WalletPage/index.tsx b/src/pages/settings/Wallet/WalletPage/index.tsx index 18b8fb588148..a95f057c6650 100644 --- a/src/pages/settings/Wallet/WalletPage/index.tsx +++ b/src/pages/settings/Wallet/WalletPage/index.tsx @@ -250,12 +250,15 @@ function WalletPage() { } else if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD && fundID) { deletePaymentCard(fundID); } + setShowConfirmDeleteModal(false); + resetSelectedPaymentMethodData(); }, [ paymentMethod.selectedPaymentMethod.bankAccountID, paymentMethod.selectedPaymentMethod.fundID, - paymentMethod.selectedPaymentMethodType, paymentMethod.isSelectedPaymentMethodDefault, + paymentMethod.selectedPaymentMethodType, paymentMethod.methodID, + resetSelectedPaymentMethodData, fundList, bankAccountList, styles, From 575d49cb1513036b9a220e6b2b9ff138eb9fed0f Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 30 Jan 2026 15:31:46 +0700 Subject: [PATCH 7/9] fix comments --- src/libs/actions/BankAccounts.ts | 11 ++++--- src/libs/actions/PaymentMethods.ts | 2 +- .../settings/Wallet/WalletPage/index.tsx | 33 ++++++------------- 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 179f2316d727..6ca9e4af142b 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -394,7 +394,6 @@ function deletePaymentBankAccount( lastUsedPaymentMethods?: LastPaymentMethod, bankAccount?: OnyxEntry, newBankAccountID?: number, - newFundID?: number, ) { const parameters: DeletePaymentBankAccountParams = {bankAccountID}; @@ -404,7 +403,7 @@ function deletePaymentBankAccount( pendingAction: null, }; - const onyxData: OnyxData = { + const onyxData: OnyxData = { optimisticData: [ { onyxMethod: Onyx.METHOD.MERGE, @@ -434,9 +433,11 @@ function deletePaymentBankAccount( ], }; - if (newBankAccountID && !!newFundID) { - const newDefaultPaymentMethodOnyxData = getMakeDefaultPaymentOnyxData(newBankAccountID, newFundID); - onyxData.optimisticData?.push(...newDefaultPaymentMethodOnyxData); + if (newBankAccountID) { + const newDefaultPaymentMethodOnyxData = getMakeDefaultPaymentOnyxData(newBankAccountID); + onyxData.optimisticData?.push( + ...(newDefaultPaymentMethodOnyxData as Array>), + ); } for (const paymentMethodID of Object.keys(lastUsedPaymentMethods ?? {})) { const lastUsedPaymentMethod = lastUsedPaymentMethods?.[paymentMethodID] as LastPaymentMethodType; diff --git a/src/libs/actions/PaymentMethods.ts b/src/libs/actions/PaymentMethods.ts index 5b9eb44dab24..1d56a82ff250 100644 --- a/src/libs/actions/PaymentMethods.ts +++ b/src/libs/actions/PaymentMethods.ts @@ -78,7 +78,7 @@ function getPaymentMethods(includePartiallySetupBankAccounts?: boolean) { function getMakeDefaultPaymentOnyxData( bankAccountID: number, - fundID: number, + fundID?: number, previousPaymentMethod?: PaymentMethod, currentPaymentMethod?: PaymentMethod, isOptimisticData = true, diff --git a/src/pages/settings/Wallet/WalletPage/index.tsx b/src/pages/settings/Wallet/WalletPage/index.tsx index a7b813590339..89b0d897e649 100644 --- a/src/pages/settings/Wallet/WalletPage/index.tsx +++ b/src/pages/settings/Wallet/WalletPage/index.tsx @@ -224,31 +224,19 @@ function WalletPage() { const bankAccountID = paymentMethod.selectedPaymentMethod.bankAccountID; const fundID = paymentMethod.selectedPaymentMethod.fundID; let newBankAccountID: number | undefined; - let newFundID: number | undefined; if (paymentMethod.isSelectedPaymentMethodDefault) { const paymentCardList = fundList ?? {}; const allPaymentMethods = formatPaymentMethods(bankAccountList ?? {}, paymentCardList, styles, translate); const remainingPaymentMethods = allPaymentMethods - .filter((method) => { - if (method.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && method.accountData?.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS) { - return false; - } - - if (method.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && method.accountData?.state !== CONST.BANK_ACCOUNT.STATE.OPEN) { - return false; - } - - if (method.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { - return false; - } - - if (method.methodID === paymentMethod.methodID) { - return false; - } - - return true; - }) + .filter( + (method) => + method.methodID !== paymentMethod.methodID && + method.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && + method.accountData?.type !== CONST.BANK_ACCOUNT.TYPE.BUSINESS && + method.accountData?.state === CONST.BANK_ACCOUNT.STATE.OPEN && + method.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, + ) .sort((a, b) => { const aCreated = a.accountData?.created ?? ''; const bCreated = b.accountData?.created ?? ''; @@ -264,14 +252,13 @@ function WalletPage() { if (remainingPaymentMethods.length > 0) { const newDefaultMethod = remainingPaymentMethods.at(0); newBankAccountID = - newDefaultMethod?.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod?.accountData?.bankAccountID ?? CONST.DEFAULT_NUMBER_ID) : 0; - newFundID = newDefaultMethod?.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD ? (newDefaultMethod?.accountData?.fundID ?? CONST.DEFAULT_NUMBER_ID) : 0; + newDefaultMethod?.accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? (newDefaultMethod?.accountData?.bankAccountID ?? CONST.DEFAULT_NUMBER_ID) : undefined; } } if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && bankAccountID) { const bankAccount = bankAccountList?.[paymentMethod.methodID] ?? {}; - deletePaymentBankAccount(bankAccountID, personalPolicyID, lastUsedPaymentMethods, bankAccount, newBankAccountID, newFundID); + deletePaymentBankAccount(bankAccountID, personalPolicyID, lastUsedPaymentMethods, bankAccount, newBankAccountID); } else if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD && fundID) { deletePaymentCard(fundID); } From 81d9630738e066302a745afd6868605f0e2f45dd Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 11 Feb 2026 22:34:20 +0700 Subject: [PATCH 8/9] fix comments --- src/libs/actions/BankAccounts.ts | 8 ++++++++ src/pages/settings/Wallet/WalletPage/index.tsx | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 3261b0eed251..c7089e01b101 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -438,6 +438,14 @@ function deletePaymentBankAccount( onyxData.optimisticData?.push( ...(newDefaultPaymentMethodOnyxData as Array>), ); + onyxData.failureData?.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.USER_WALLET, + value: { + walletLinkedAccountID: bankAccountID, + walletLinkedAccountType: CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT, + }, + }); } for (const paymentMethodID of Object.keys(lastUsedPaymentMethods ?? {})) { const lastUsedPaymentMethod = lastUsedPaymentMethods?.[paymentMethodID] as LastPaymentMethodType; diff --git a/src/pages/settings/Wallet/WalletPage/index.tsx b/src/pages/settings/Wallet/WalletPage/index.tsx index b193cc92f093..1ef514700410 100644 --- a/src/pages/settings/Wallet/WalletPage/index.tsx +++ b/src/pages/settings/Wallet/WalletPage/index.tsx @@ -242,6 +242,9 @@ function WalletPage() { .sort((a, b) => { const aCreated = a.accountData?.created ?? ''; const bCreated = b.accountData?.created ?? ''; + if (!aCreated && !bCreated) { + return 0; + } if (!aCreated) { return 1; } From f7cd06396cacec583be50d8c3dceec83f01e1e2d Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 23 Feb 2026 11:10:22 +0700 Subject: [PATCH 9/9] fix add the isDefault value --- src/libs/actions/BankAccounts.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index e5b3c5e6b6fd..331ed33c508a 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -438,6 +438,15 @@ function deletePaymentBankAccount( onyxData.optimisticData?.push( ...(newDefaultPaymentMethodOnyxData as Array>), ); + onyxData.optimisticData?.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.BANK_ACCOUNT_LIST, + value: { + [newBankAccountID]: { + isDefault: true, + }, + }, + }); onyxData.failureData?.push({ onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.USER_WALLET, @@ -446,6 +455,15 @@ function deletePaymentBankAccount( walletLinkedAccountType: CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT, }, }); + onyxData.failureData?.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.BANK_ACCOUNT_LIST, + value: { + [newBankAccountID]: { + isDefault: false, + }, + }, + }); } for (const paymentMethodID of Object.keys(lastUsedPaymentMethods ?? {})) { const lastUsedPaymentMethod = lastUsedPaymentMethods?.[paymentMethodID] as LastPaymentMethodType;