From 002fa0930f5d6f0403c08c865d572cdcf394e7d7 Mon Sep 17 00:00:00 2001 From: Scott Deeter Date: Fri, 21 Nov 2025 15:56:41 -0800 Subject: [PATCH] Revert "Merge pull request #74628 from Tony-MK/putOnHold" This reverts commit 5c64aa808e6f14a974a2991974c9aed255e2d77a, reversing changes made to 94d32723d0187cb8e8806edb449875a32e70b0da. --- src/libs/actions/IOU.ts | 20 +++++++++++++------- src/pages/Search/SearchHoldReasonPage.tsx | 12 ++++-------- src/pages/iou/HoldReasonPage.tsx | 4 +--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c8b0415eb893..2f8652abe41d 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -115,7 +115,7 @@ import { isMoneyRequestAction, isReportPreviewAction, } from '@libs/ReportActionsUtils'; -import type {Ancestor, OptimisticChatReport, OptimisticCreatedReportAction, OptimisticIOUReportAction, OptionData, TransactionDetails} from '@libs/ReportUtils'; +import type {OptimisticChatReport, OptimisticCreatedReportAction, OptimisticIOUReportAction, OptionData, TransactionDetails} from '@libs/ReportUtils'; import { buildOptimisticActionableTrackExpenseWhisper, buildOptimisticAddCommentReportAction, @@ -158,7 +158,7 @@ import { getDisplayedReportID, getMoneyRequestSpendBreakdown, getNextApproverAccountID, - getOptimisticDataForAncestors, + getOptimisticDataForParentReportAction, getOutstandingChildRequest, getParsedComment, getPersonalDetailsForAccountID, @@ -11967,7 +11967,7 @@ function adjustRemainingSplitShares(transaction: NonNullable notifyNewAction(currentReportID, userAccountID)); } -function putTransactionsOnHold(transactionsID: string[], comment: string, reportID: string, ancestors: Ancestor[] = []) { +function putTransactionsOnHold(transactionsID: string[], comment: string, reportID: string) { for (const transactionID of transactionsID) { const {childReportID} = getIOUActionForReportID(reportID, transactionID) ?? {}; - putOnHold(transactionID, comment, childReportID, ancestors); + putOnHold(transactionID, comment, childReportID); } } diff --git a/src/pages/Search/SearchHoldReasonPage.tsx b/src/pages/Search/SearchHoldReasonPage.tsx index 5b1344bcd0f1..50abf63ab9ed 100644 --- a/src/pages/Search/SearchHoldReasonPage.tsx +++ b/src/pages/Search/SearchHoldReasonPage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useEffect} from 'react'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; import {useSearchContext} from '@components/Search/SearchContext'; -import useAncestors from '@hooks/useAncestors'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import {clearErrorFields, clearErrors} from '@libs/actions/FormActions'; @@ -25,24 +24,21 @@ function SearchHoldReasonPage({route}: SearchHoldReasonPageProps) { const {backTo = '', reportID} = route.params ?? {}; const context = useSearchContext(); const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: true}); - const [allReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {canBeMissing: true}); - - const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); - const ancestors = useAncestors(report); + const [allReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {canBeMissing: true}); const onSubmit = useCallback( ({comment}: FormOnyxValues) => { if (route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT_HOLD_TRANSACTIONS) { - putTransactionsOnHold(context.selectedTransactionIDs, comment, reportID, ancestors); + putTransactionsOnHold(context.selectedTransactionIDs, comment, reportID); context.clearSelectedTransactions(true); } else { - holdMoneyRequestOnSearch(context.currentSearchHash, context.selectedTransactionIDs, comment, allTransactions, allReportActions); + holdMoneyRequestOnSearch(context.currentSearchHash, Object.keys(context.selectedTransactions), comment, allTransactions, allReportActions); context.clearSelectedTransactions(); } Navigation.goBack(); }, - [route.name, context.clearSelectedTransactions, context.currentSearchHash, context.selectedTransactionIDs, reportID, allTransactions, ancestors, allReportActions], + [route.name, context, reportID, allTransactions, allReportActions], ); const validate = useCallback( diff --git a/src/pages/iou/HoldReasonPage.tsx b/src/pages/iou/HoldReasonPage.tsx index e5682aa73459..6f101882b5a2 100644 --- a/src/pages/iou/HoldReasonPage.tsx +++ b/src/pages/iou/HoldReasonPage.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useEffect} from 'react'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; import {useSearchContext} from '@components/Search/SearchContext'; -import useAncestors from '@hooks/useAncestors'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import {addErrorMessage} from '@libs/ErrorUtils'; @@ -28,7 +27,6 @@ function HoldReasonPage({route}: HoldReasonPageProps) { const {transactionID, reportID, backTo} = route.params; const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); - const ancestors = useAncestors(report); const {selectedTransactionIDs} = useSearchContext(); // We first check if the report is part of a policy - if not, then it's a personal request (1:1 request) @@ -44,7 +42,7 @@ function HoldReasonPage({route}: HoldReasonPageProps) { return; } - putOnHold(transactionID, values.comment, reportID, ancestors); + putOnHold(transactionID, values.comment, reportID); Navigation.goBack(backTo); };