From 3911a9ec53e1d552d34c6e09715e96b3f3a3607a Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 15 Apr 2024 15:48:58 +0700 Subject: [PATCH 1/3] Fix disconnected bank account still displayed in workflow page --- ios/Podfile.lock | 10 ++++---- .../resetFreePlanBankAccount.ts | 25 ++++++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index f9244c515a2c..c4d42df41b97 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1945,7 +1945,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNScreens (3.30.1): + - RNScreens (3.29.0): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -1963,9 +1963,9 @@ PODS: - React-utils - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNScreens/common (= 3.30.1) + - RNScreens/common (= 3.29.0) - Yoga - - RNScreens/common (3.30.1): + - RNScreens/common (3.29.0): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -2571,7 +2571,7 @@ SPEC CHECKSUMS: RNPermissions: 8990fc2c10da3640938e6db1647cb6416095b729 RNReactNativeHapticFeedback: 616c35bdec7d20d4c524a7949ca9829c09e35f37 RNReanimated: 605409e0d0ced6f2e194ae585fedc2f8a1935bf2 - RNScreens: 65a936f4e227b91e4a8e2a7d4c4607355bfefda0 + RNScreens: f7b8bb892b4957f6f91e5dfd9a191e7f13ce8baa RNShare: 2a4cdfc0626ad56b0ef583d424f2038f772afe58 RNSound: 6c156f925295bdc83e8e422e7d8b38d33bc71852 RNSVG: db32cfcad0a221fd175e0882eff7bcba7690380a @@ -2582,7 +2582,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 + Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d diff --git a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts index a1f0e070fcb3..df558f81a503 100644 --- a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts +++ b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts @@ -1,4 +1,4 @@ -import type {OnyxEntry} from 'react-native-onyx'; +import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; import {WRITE_COMMANDS} from '@libs/API/types'; @@ -10,6 +10,13 @@ import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; import type * as OnyxTypes from '@src/types/onyx'; +let allPolicies: OnyxCollection; +Onyx.connect({ + key: ONYXKEYS.COLLECTION.POLICY, + waitForCollectionCallback: true, + callback: (value) => (allPolicies = value), +}); + /** * Reset user's reimbursement account. This will delete the bank account. */ @@ -21,6 +28,8 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On throw new Error('Missing credentials when attempting to reset free plan bank account'); } + const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as Policy); + API.write( WRITE_COMMANDS.RESTART_BANK_ACCOUNT_SETUP, { @@ -40,6 +49,13 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On achData: null, }, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + achAccount: null, + }, + }, ], successData: [ { @@ -119,6 +135,13 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, value: {isLoading: false, pendingAction: null}, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + achAccount: policy?.achAccount, + }, + }, ], }, ); From b0b0992dd893347acf4cab18678c1b841608a93a Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 15 Apr 2024 20:38:00 +0700 Subject: [PATCH 2/3] fix ts check --- .../actions/ReimbursementAccount/resetFreePlanBankAccount.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts index df558f81a503..41fa0a4ccbd0 100644 --- a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts +++ b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.ts @@ -28,7 +28,7 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On throw new Error('Missing credentials when attempting to reset free plan bank account'); } - const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as Policy); + const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`] ?? ({} as OnyxTypes.Policy); API.write( WRITE_COMMANDS.RESTART_BANK_ACCOUNT_SETUP, From 8d6a4a9ad0cbe1cfd263af5cc76cfd94d85551ba Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 16 Apr 2024 16:39:07 +0700 Subject: [PATCH 3/3] revert unnecessary change --- ios/Podfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 5f0d1e356c89..1ebfc6bb1b62 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1944,7 +1944,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNScreens (3.29.0): + - RNScreens (3.30.1): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -1962,9 +1962,9 @@ PODS: - React-utils - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNScreens/common (= 3.29.0) + - RNScreens/common (= 3.30.1) - Yoga - - RNScreens/common (3.29.0): + - RNScreens/common (3.30.1): - glog - hermes-engine - RCT-Folly (= 2022.05.16.00) @@ -2570,7 +2570,7 @@ SPEC CHECKSUMS: RNPermissions: 8990fc2c10da3640938e6db1647cb6416095b729 RNReactNativeHapticFeedback: 616c35bdec7d20d4c524a7949ca9829c09e35f37 RNReanimated: 605409e0d0ced6f2e194ae585fedc2f8a1935bf2 - RNScreens: f7b8bb892b4957f6f91e5dfd9a191e7f13ce8baa + RNScreens: 65a936f4e227b91e4a8e2a7d4c4607355bfefda0 RNShare: 2a4cdfc0626ad56b0ef583d424f2038f772afe58 RNSound: 6c156f925295bdc83e8e422e7d8b38d33bc71852 RNSVG: db32cfcad0a221fd175e0882eff7bcba7690380a @@ -2581,7 +2581,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 3033e0dd5272d46e97bcb406adea4ae0e6907abf - Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 + Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 PODFILE CHECKSUM: a25a81f2b50270f0c0bd0aff2e2ebe4d0b4ec06d