From 2f35d966547e6d14a94ae676ad3d0476c93452b1 Mon Sep 17 00:00:00 2001 From: Puneet Lath Date: Thu, 11 Sep 2025 16:45:06 -0400 Subject: [PATCH] Revert "Start Over in bank account does not clear data" --- .../resetNonUSDBankAccount.ts | 28 ++----------------- .../ReimbursementAccountPage.tsx | 2 +- .../WorkspaceResetBankAccountModal.tsx | 2 +- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/libs/actions/ReimbursementAccount/resetNonUSDBankAccount.ts b/src/libs/actions/ReimbursementAccount/resetNonUSDBankAccount.ts index 96c664ef03f2..a4cb9bc0e614 100644 --- a/src/libs/actions/ReimbursementAccount/resetNonUSDBankAccount.ts +++ b/src/libs/actions/ReimbursementAccount/resetNonUSDBankAccount.ts @@ -1,40 +1,16 @@ import Onyx from 'react-native-onyx'; -import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import * as API from '@libs/API'; import {WRITE_COMMANDS} from '@libs/API/types'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ACHAccount} from '@src/types/onyx/Policy'; -function resetNonUSDBankAccount(policyID: string | undefined, achAccount: OnyxEntry, shouldResetLocally: boolean) { +function resetNonUSDBankAccount(policyID: string | undefined, achAccount: OnyxEntry) { if (!policyID) { throw new Error('Missing policy when attempting to reset'); } - if (shouldResetLocally) { - const updateData = [ - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, - value: null, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - achAccount: null, - }, - }, - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA, - }, - ]; - Onyx.update(updateData as OnyxUpdate[]); - return; - } - API.write( WRITE_COMMANDS.RESET_BANK_ACCOUNT_SETUP, {policyID}, diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx index a03cba87f9b3..8cbd2a769c5a 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.tsx @@ -199,7 +199,7 @@ function ReimbursementAccountPage({route, policy, isLoadingPolicy, navigation}: } fetchData(); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps - }, [isPreviousPolicy]); // Only re-run this effect when isPreviousPolicy changes, which happens once when the component first loads + }, []); // The empty dependency array ensures this runs only once after the component mounts. useEffect(() => { if (!isPreviousPolicy) { diff --git a/src/pages/workspace/WorkspaceResetBankAccountModal.tsx b/src/pages/workspace/WorkspaceResetBankAccountModal.tsx index c60f59cdc2e8..405dd6f2d56e 100644 --- a/src/pages/workspace/WorkspaceResetBankAccountModal.tsx +++ b/src/pages/workspace/WorkspaceResetBankAccountModal.tsx @@ -55,7 +55,7 @@ function WorkspaceResetBankAccountModal({ const handleConfirm = () => { if (isNonUSDWorkspace) { - resetNonUSDBankAccount(policyID, policy?.achAccount, !achData?.bankAccountID); + resetNonUSDBankAccount(policyID, policy?.achAccount); if (setShouldShowConnectedVerifiedBankAccount) { setShouldShowConnectedVerifiedBankAccount(false);