From df53dc95ee583842fda0b75ff76428ebef0d6f69 Mon Sep 17 00:00:00 2001 From: NikkiWines Date: Tue, 2 Apr 2024 12:41:07 -0700 Subject: [PATCH 1/2] ensure we don't show optimistic preview action for one-transaction reports --- src/pages/home/report/ReportActionsView.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 1b6a9614a466..5a9d29b36ace 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -482,12 +482,12 @@ function ReportActionsView({ // and we also generate a money request action if the number of money requests in reportActions is less than the total number of money requests // to display at least one money request action to match the total data. const reportActionsToDisplay = useMemo(() => { - if (!ReportUtils.isMoneyRequestReport(report) || !reportActions.length) { - return reportActions; + if (!ReportUtils.isMoneyRequestReport(report) || !combinedReportActions.length) { + return combinedReportActions; } - const actions = [...reportActions]; - const lastAction = reportActions[reportActions.length - 1]; + const actions = [...combinedReportActions]; + const lastAction = combinedReportActions[combinedReportActions.length - 1]; if (!ReportActionsUtils.isCreatedAction(lastAction)) { const optimisticCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(String(report?.ownerAccountID), DateUtils.subtractMillisecondsFromDateTime(lastAction.created, 1)); @@ -500,7 +500,7 @@ function ReportActionsView({ (action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && action.originalMessage && action.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE, ); - if (report.total && moneyRequestActions.length < (reportPreviewAction?.childMoneyRequestCount ?? 0)) { + if (report.total && moneyRequestActions.length < (reportPreviewAction?.childMoneyRequestCount ?? 0) && isEmptyObject(transactionThreadReport)) { const optimisticIOUAction = ReportUtils.buildOptimisticIOUReportAction( CONST.IOU.REPORT_ACTION_TYPE.CREATE, 0, @@ -528,7 +528,7 @@ function ReportActionsView({ } return [...actions, createdAction]; - }, [reportActions, report]); + }, [combinedReportActions, report, transactionThreadReport]); // Comments have not loaded at all yet do nothing if (!reportActions.length) { From 0d2a5aafc765cdc430a7dea067d63f346111be46 Mon Sep 17 00:00:00 2001 From: NikkiWines Date: Tue, 2 Apr 2024 13:40:46 -0700 Subject: [PATCH 2/2] don't used combinedReportActions actually --- src/pages/home/report/ReportActionsView.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 5a9d29b36ace..1c00ebce0579 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -482,12 +482,12 @@ function ReportActionsView({ // and we also generate a money request action if the number of money requests in reportActions is less than the total number of money requests // to display at least one money request action to match the total data. const reportActionsToDisplay = useMemo(() => { - if (!ReportUtils.isMoneyRequestReport(report) || !combinedReportActions.length) { - return combinedReportActions; + if (!ReportUtils.isMoneyRequestReport(report) || !reportActions.length) { + return reportActions; } - const actions = [...combinedReportActions]; - const lastAction = combinedReportActions[combinedReportActions.length - 1]; + const actions = [...reportActions]; + const lastAction = reportActions[reportActions.length - 1]; if (!ReportActionsUtils.isCreatedAction(lastAction)) { const optimisticCreatedAction = ReportUtils.buildOptimisticCreatedReportAction(String(report?.ownerAccountID), DateUtils.subtractMillisecondsFromDateTime(lastAction.created, 1)); @@ -528,7 +528,7 @@ function ReportActionsView({ } return [...actions, createdAction]; - }, [combinedReportActions, report, transactionThreadReport]); + }, [reportActions, report, transactionThreadReport]); // Comments have not loaded at all yet do nothing if (!reportActions.length) {