From 1fff9088b553e51fa5520fb009e5ebc8fd61cabf Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 4 Nov 2024 14:14:22 +0700 Subject: [PATCH 01/15] fix: loading indicator display when deleting vague distance Expense --- src/components/ReportActionItem/MoneyRequestView.tsx | 7 +++++-- src/libs/actions/IOU.ts | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index b85ecad20f2e..96b66dfeb7fa 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -1,5 +1,5 @@ import React, {useCallback, useMemo} from 'react'; -import {View} from 'react-native'; +import {InteractionManager, View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -484,8 +484,11 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals return; } if (parentReportAction) { - const urlToNavigateBack = IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); + const {urlToNavigateBack} = IOU.prepareToCleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); Navigation.goBack(urlToNavigateBack); + InteractionManager.runAfterInteractions(() => { + IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); + }); return; } } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 6893a66f2050..9e0285aace0c 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -8568,6 +8568,7 @@ export { completePaymentOnboarding, payInvoice, payMoneyRequest, + prepareToCleanUpMoneyRequest, putOnHold, replaceReceipt, requestMoney, From fcf7f3ffa2d99a44ede87ed0f23605c72a35ac01 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 11 Nov 2024 11:47:00 +0700 Subject: [PATCH 02/15] remove InteractionManager.runAfterInteractions --- src/components/ReportActionItem/MoneyRequestView.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 0d771cd95239..e31f5c640309 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -463,9 +463,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals if (parentReportAction) { const {urlToNavigateBack} = IOU.prepareToCleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); Navigation.goBack(urlToNavigateBack); - InteractionManager.runAfterInteractions(() => { - IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); - }); + IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); return; } } From 65b343bfbfa75a3385f83c6de732fbec412961b6 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 11 Nov 2024 11:47:29 +0700 Subject: [PATCH 03/15] fix: remove unused lib --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index e31f5c640309..4ee583b346fe 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -1,5 +1,5 @@ import React, {useCallback, useMemo} from 'react'; -import {InteractionManager, View} from 'react-native'; +import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; From 10fb70b595d6ce251dbdc0765ec49aa406397971 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 11 Nov 2024 11:53:13 +0700 Subject: [PATCH 04/15] fix: revert remove InteractionManager.runAfterInteractions --- src/components/ReportActionItem/MoneyRequestView.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 4ee583b346fe..0d771cd95239 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -1,5 +1,5 @@ import React, {useCallback, useMemo} from 'react'; -import {View} from 'react-native'; +import {InteractionManager, View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -463,7 +463,9 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals if (parentReportAction) { const {urlToNavigateBack} = IOU.prepareToCleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); Navigation.goBack(urlToNavigateBack); - IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); + InteractionManager.runAfterInteractions(() => { + IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); + }); return; } } From d332cb7689d43b7e5bd4d4b40258b61c5ca6782b Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 3 Dec 2024 10:18:36 +0700 Subject: [PATCH 05/15] fix: clear action first then navigate back then clear rest --- .../ReportActionItem/MoneyRequestView.tsx | 1 + src/libs/actions/IOU.ts | 42 ++++++++++--------- src/pages/home/ReportScreen.tsx | 4 +- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 242f1f32d962..0ba488d447ba 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -469,6 +469,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals } if (parentReportAction) { const {urlToNavigateBack} = IOU.prepareToCleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); + IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true, true); Navigation.goBack(urlToNavigateBack); InteractionManager.runAfterInteractions(() => { IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 1277a649b713..6a724c4c35d5 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5589,7 +5589,7 @@ function prepareToCleanUpMoneyRequest(transactionID: string, reportAction: OnyxT * @param isSingleTransactionView - whether we are in the transaction thread report * @return the url to navigate back once the money request is deleted */ -function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false) { +function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, onlyCleanupActions = false) { const { shouldDeleteTransactionThread, shouldDeleteIOUReport, @@ -5606,27 +5606,28 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo // build Onyx data // Onyx operations to delete the transaction, update the IOU report action and chat report action + const onyxUpdatesActions: OnyxUpdate[] = []; const onyxUpdates: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, value: null, }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, - value: { - [reportAction.reportActionID]: shouldDeleteIOUReport - ? null - : { - pendingAction: null, - }, - }, - }, ]; + onyxUpdatesActions.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, + value: { + [reportAction.reportActionID]: shouldDeleteIOUReport + ? null + : { + pendingAction: null, + }, + }, + }); if (reportPreviewAction?.reportActionID) { - onyxUpdates.push({ + onyxUpdatesActions.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`, value: { @@ -5663,12 +5664,12 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo } // added operations to update IOU report and chat report + onyxUpdatesActions.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, + value: updatedReportAction, + }); onyxUpdates.push( - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, - value: updatedReportAction, - }, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`, @@ -5719,7 +5720,10 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo ); } - Onyx.update(onyxUpdates); + Onyx.update(onyxUpdatesActions); + if (!onlyCleanupActions) { + Onyx.update(onyxUpdates); + } return urlToNavigateBack; } diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 561323aa069f..6a520974f8ad 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -370,7 +370,9 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro isLoadingReportOnyx || !isCurrentReportLoadedFromOnyx || isLoading; - + if(report?.reportID === '3167588647183926'){ + console.log("3333333333333333", {shouldShowSkeleton, v1: isLinkingToMessage && !isLinkedMessagePageReady, v2: !isLinkingToMessage && !isInitialPageReady}) + } const isLinkedActionBecomesDeleted = prevIsLinkedActionDeleted !== undefined && !prevIsLinkedActionDeleted && isLinkedActionDeleted; // eslint-disable-next-line rulesdir/no-negated-variables From 12a0a686882e77c8c3ce78cf62d3a507a9cdd019 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 3 Dec 2024 10:46:34 +0700 Subject: [PATCH 06/15] fix: add isWeb logic --- .../ReportActionItem/MoneyRequestView.tsx | 11 +++++++++-- src/libs/actions/IOU.ts | 13 +++++++++---- src/pages/home/ReportScreen.tsx | 3 --- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 0ba488d447ba..79615c030111 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -21,6 +21,7 @@ import useViolations from '@hooks/useViolations'; import type {ViolationField} from '@hooks/useViolations'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; +import getPlatform from '@libs/getPlatform'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import {isTaxTrackingEnabled} from '@libs/PolicyUtils'; @@ -468,11 +469,17 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals return; } if (parentReportAction) { + const isWeb = getPlatform() === CONST.PLATFORM.WEB; const {urlToNavigateBack} = IOU.prepareToCleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true, true); - Navigation.goBack(urlToNavigateBack); + if (isWeb) { + Navigation.goBack(urlToNavigateBack); + } InteractionManager.runAfterInteractions(() => { - IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); + if (!isWeb) { + Navigation.goBack(urlToNavigateBack); + } + IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true, false); }); return; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 6a724c4c35d5..239edf8e1efb 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5589,7 +5589,7 @@ function prepareToCleanUpMoneyRequest(transactionID: string, reportAction: OnyxT * @param isSingleTransactionView - whether we are in the transaction thread report * @return the url to navigate back once the money request is deleted */ -function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, onlyCleanupActions = false) { +function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, onlyCleanupActions) { const { shouldDeleteTransactionThread, shouldDeleteIOUReport, @@ -5720,9 +5720,14 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo ); } - Onyx.update(onyxUpdatesActions); - if (!onlyCleanupActions) { - Onyx.update(onyxUpdates); + if (onlyCleanupActions === undefined) { + Onyx.update([...onyxUpdates, ...onyxUpdatesActions]); + } else { + if (onlyCleanupActions === true) { + Onyx.update(onyxUpdatesActions); + } else { + Onyx.update(onyxUpdates); + } } return urlToNavigateBack; diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 6a520974f8ad..aeb61e35b356 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -370,9 +370,6 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro isLoadingReportOnyx || !isCurrentReportLoadedFromOnyx || isLoading; - if(report?.reportID === '3167588647183926'){ - console.log("3333333333333333", {shouldShowSkeleton, v1: isLinkingToMessage && !isLinkedMessagePageReady, v2: !isLinkingToMessage && !isInitialPageReady}) - } const isLinkedActionBecomesDeleted = prevIsLinkedActionDeleted !== undefined && !prevIsLinkedActionDeleted && isLinkedActionDeleted; // eslint-disable-next-line rulesdir/no-negated-variables From 70fb37df9de5fd5d70f223534e053363558dfabc Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 3 Dec 2024 10:47:21 +0700 Subject: [PATCH 07/15] fix: revert unused change --- src/pages/home/ReportScreen.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index aeb61e35b356..561323aa069f 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -370,6 +370,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro isLoadingReportOnyx || !isCurrentReportLoadedFromOnyx || isLoading; + const isLinkedActionBecomesDeleted = prevIsLinkedActionDeleted !== undefined && !prevIsLinkedActionDeleted && isLinkedActionDeleted; // eslint-disable-next-line rulesdir/no-negated-variables From 173a51e097a689ed5bd6ca17b3b158870e8e1d21 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 3 Dec 2024 10:51:10 +0700 Subject: [PATCH 08/15] fix: lint --- src/libs/actions/IOU.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 239edf8e1efb..36490dfd1199 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5587,9 +5587,10 @@ function prepareToCleanUpMoneyRequest(transactionID: string, reportAction: OnyxT * @param transactionID - The transactionID of IOU * @param reportAction - The reportAction of the transaction in the IOU report * @param isSingleTransactionView - whether we are in the transaction thread report + * @param onlyCleanupActions - whether we only clear the reportActions data * @return the url to navigate back once the money request is deleted */ -function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, onlyCleanupActions) { +function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, onlyCleanupActions: boolean) { const { shouldDeleteTransactionThread, shouldDeleteIOUReport, From 8353a829cd88f62358582e5136d660462dea1b76 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 3 Dec 2024 10:56:05 +0700 Subject: [PATCH 09/15] fix: lint --- src/libs/actions/IOU.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 36490dfd1199..ced9511c90d5 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5590,7 +5590,7 @@ function prepareToCleanUpMoneyRequest(transactionID: string, reportAction: OnyxT * @param onlyCleanupActions - whether we only clear the reportActions data * @return the url to navigate back once the money request is deleted */ -function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, onlyCleanupActions: boolean) { +function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, onlyCleanupActions = false) { const { shouldDeleteTransactionThread, shouldDeleteIOUReport, @@ -5721,15 +5721,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo ); } - if (onlyCleanupActions === undefined) { - Onyx.update([...onyxUpdates, ...onyxUpdatesActions]); - } else { - if (onlyCleanupActions === true) { - Onyx.update(onyxUpdatesActions); - } else { - Onyx.update(onyxUpdates); - } - } + Onyx.update(onlyCleanupActions ? onyxUpdatesActions : onyxUpdates); return urlToNavigateBack; } From a90580ab4da5b0abbda96fc3033a092e3a9a3850 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 6 Dec 2024 09:34:35 +0700 Subject: [PATCH 10/15] fix: move all update logic to cleanUpMoneyRequest --- .../ReportActionItem/MoneyRequestView.tsx | 13 +------------ src/libs/actions/IOU.ts | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 79615c030111..b65ff708275a 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -469,18 +469,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals return; } if (parentReportAction) { - const isWeb = getPlatform() === CONST.PLATFORM.WEB; - const {urlToNavigateBack} = IOU.prepareToCleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); - IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true, true); - if (isWeb) { - Navigation.goBack(urlToNavigateBack); - } - InteractionManager.runAfterInteractions(() => { - if (!isWeb) { - Navigation.goBack(urlToNavigateBack); - } - IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true, false); - }); + IOU.cleanUpMoneyRequest(transaction?.transactionID ?? linkedTransactionID, parentReportAction, true); return; } } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 483ff7d6a911..94c5a8782095 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -35,6 +35,7 @@ import DateUtils from '@libs/DateUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import * as FileUtils from '@libs/fileDownload/FileUtils'; +import getPlatform from '@libs/getPlatform'; import GoogleTagManager from '@libs/GoogleTagManager'; import * as IOUUtils from '@libs/IOUUtils'; import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; @@ -5676,7 +5677,7 @@ function getNavigationUrlAfterTrackExpenseDelete(chatReportID: string, transacti * @param onlyCleanupActions - whether we only clear the reportActions data * @return the url to navigate back once the money request is deleted */ -function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false, onlyCleanupActions = false) { +function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false) { const { shouldDeleteTransactionThread, shouldDeleteIOUReport, @@ -5807,9 +5808,21 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo ); } - Onyx.update(onlyCleanupActions ? onyxUpdatesActions : onyxUpdates); + // First, update the reportActions to ensure related actions are not displayed. + Onyx.update(onyxUpdatesActions); + const isWeb = getPlatform() === CONST.PLATFORM.WEB; - return urlToNavigateBack; + // On web, navigation should happen immediately after updating reportActions. + if (isWeb) { + Navigation.goBack(urlToNavigateBack); + } + InteractionManager.runAfterInteractions(() => { + if (!isWeb) { + Navigation.goBack(urlToNavigateBack); + } + // After navigation, update the remaining data. + Onyx.update(onyxUpdates); + }); } /** From d71f1ebc36b4049146ef5a5b7cacf60c8aa8435d Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 6 Dec 2024 09:37:14 +0700 Subject: [PATCH 11/15] fix: lint --- src/components/ReportActionItem/MoneyRequestView.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index b65ff708275a..1c2a552db476 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -1,5 +1,5 @@ import React, {useCallback, useMemo} from 'react'; -import {InteractionManager, View} from 'react-native'; +import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -21,7 +21,6 @@ import useViolations from '@hooks/useViolations'; import type {ViolationField} from '@hooks/useViolations'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; -import getPlatform from '@libs/getPlatform'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; import {isTaxTrackingEnabled} from '@libs/PolicyUtils'; From 4149884a3a8ada9ffa65e2798fb0dec984ff33ef Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 6 Dec 2024 09:58:08 +0700 Subject: [PATCH 12/15] fix: use promise --- src/libs/actions/IOU.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 94c5a8782095..cf8e9714f549 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5809,19 +5809,12 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo } // First, update the reportActions to ensure related actions are not displayed. - Onyx.update(onyxUpdatesActions); - const isWeb = getPlatform() === CONST.PLATFORM.WEB; - - // On web, navigation should happen immediately after updating reportActions. - if (isWeb) { + Onyx.update(onyxUpdatesActions).then(() => { Navigation.goBack(urlToNavigateBack); - } - InteractionManager.runAfterInteractions(() => { - if (!isWeb) { - Navigation.goBack(urlToNavigateBack); - } - // After navigation, update the remaining data. - Onyx.update(onyxUpdates); + InteractionManager.runAfterInteractions(() => { + // After navigation, update the remaining data. + Onyx.update(onyxUpdates); + }); }); } From 5117becdc6c857219dff927aec59345e8949b928 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 6 Dec 2024 09:59:22 +0700 Subject: [PATCH 13/15] fix: lint --- src/libs/actions/IOU.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index cf8e9714f549..8ec501b2422f 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -35,7 +35,6 @@ import DateUtils from '@libs/DateUtils'; import DistanceRequestUtils from '@libs/DistanceRequestUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import * as FileUtils from '@libs/fileDownload/FileUtils'; -import getPlatform from '@libs/getPlatform'; import GoogleTagManager from '@libs/GoogleTagManager'; import * as IOUUtils from '@libs/IOUUtils'; import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; From 9d570a103e125969495eac52990d2ee4591f676d Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 6 Dec 2024 10:00:47 +0700 Subject: [PATCH 14/15] fix: remove param --- src/libs/actions/IOU.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8ec501b2422f..dc597b4be41a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5673,7 +5673,6 @@ function getNavigationUrlAfterTrackExpenseDelete(chatReportID: string, transacti * @param transactionID - The transactionID of IOU * @param reportAction - The reportAction of the transaction in the IOU report * @param isSingleTransactionView - whether we are in the transaction thread report - * @param onlyCleanupActions - whether we only clear the reportActions data * @return the url to navigate back once the money request is deleted */ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false) { From f104ffde6d69920c62287077c79d724d4f3eaa63 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 9 Dec 2024 16:13:04 +0700 Subject: [PATCH 15/15] fix: remove variable and remove unused export --- src/libs/actions/IOU.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 0507d5ba3638..6d6406deb5d9 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -5689,7 +5689,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo // build Onyx data // Onyx operations to delete the transaction, update the IOU report action and chat report action - const onyxUpdatesActions: OnyxUpdate[] = []; + const reportActionsOnyxUpdates: OnyxUpdate[] = []; const onyxUpdates: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.SET, @@ -5697,7 +5697,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo value: null, }, ]; - onyxUpdatesActions.push({ + reportActionsOnyxUpdates.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, value: { @@ -5710,7 +5710,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo }); if (reportPreviewAction?.reportActionID) { - onyxUpdatesActions.push({ + reportActionsOnyxUpdates.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`, value: { @@ -5747,7 +5747,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo } // added operations to update IOU report and chat report - onyxUpdatesActions.push({ + reportActionsOnyxUpdates.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`, value: updatedReportAction, @@ -5804,7 +5804,7 @@ function cleanUpMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repo } // First, update the reportActions to ensure related actions are not displayed. - Onyx.update(onyxUpdatesActions).then(() => { + Onyx.update(reportActionsOnyxUpdates).then(() => { Navigation.goBack(urlToNavigateBack); InteractionManager.runAfterInteractions(() => { // After navigation, update the remaining data. @@ -8672,7 +8672,6 @@ export { completePaymentOnboarding, payInvoice, payMoneyRequest, - prepareToCleanUpMoneyRequest, putOnHold, replaceReceipt, requestMoney,