From a745efe3fad66b359a6d995ef9c0847d8fd1d138 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 5 Jul 2024 11:10:35 +0700 Subject: [PATCH] Add hold option to report detail page for combine report --- src/pages/ReportDetailsPage.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index b04e56f288e9..2f477a58912c 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -165,7 +165,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD // 2. MoneyReport case if (caseID === CASES.MONEY_REPORT) { if (!reportActions || !transactionThreadReport?.parentReportActionID) { - return null; + return undefined; } return reportActions.find((action) => action.reportActionID === transactionThreadReport.parentReportActionID); } @@ -183,6 +183,8 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD return report; }, [caseID, parentReport, report]); + const moneyRequestAction = transactionThreadReportID ? requestParentReportAction : parentReportAction; + const canModifyTask = Task.canModifyTask(report, session?.accountID ?? -1); const shouldShowTaskDeleteButton = isTaskReport && @@ -446,9 +448,11 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD ? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? '' : ''; - const canHoldUnholdReportAction = ReportUtils.canHoldUnholdReportAction(parentReportAction); + const canHoldUnholdReportAction = ReportUtils.canHoldUnholdReportAction(moneyRequestAction); const shouldShowHoldAction = - caseID !== CASES.MONEY_REPORT && (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && !ReportUtils.isArchivedRoom(parentReport); + caseID !== CASES.DEFAULT && + (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && + !ReportUtils.isArchivedRoom(transactionThreadReportID ? report : parentReport); const canJoin = ReportUtils.canJoinChat(report, parentReportAction, policy); @@ -460,7 +464,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD } if (isExpenseReport && shouldShowHoldAction) { - result.push(PromotedActions.hold({isTextHold: canHoldUnholdReportAction.canHoldRequest, reportAction: parentReportAction})); + result.push(PromotedActions.hold({isTextHold: canHoldUnholdReportAction.canHoldRequest, reportAction: moneyRequestAction})); } if (report) { @@ -470,7 +474,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD result.push(PromotedActions.share(report)); return result; - }, [report, parentReportAction, canJoin, isExpenseReport, shouldShowHoldAction, canHoldUnholdReportAction.canHoldRequest]); + }, [report, moneyRequestAction, canJoin, isExpenseReport, shouldShowHoldAction, canHoldUnholdReportAction.canHoldRequest]); const nameSectionExpenseIOU = (