From 5bdf2f3eea10c8ca19a0545521e292b519abd079 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 14 Jun 2024 13:32:19 +0700 Subject: [PATCH 1/4] fix: display thread of send money request as normal thread --- src/libs/ReportActionsUtils.ts | 6 +++--- src/libs/ReportUtils.ts | 10 ++++++++-- src/pages/home/report/ReportActionItem.tsx | 5 ++--- src/pages/home/report/ReportActionItemParentAction.tsx | 1 + .../home/report/ReportActionsListItemRenderer.tsx | 4 +++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index ab951919f8b3..b14e2497e2fa 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -317,7 +317,7 @@ function getCombinedReportActions(reportActions: ReportAction[], transactionThre return reportActions; } - // Filter out the created action from the transaction thread report actions, since we already have the parent report's created action in `reportActions` + // Filter out request money actions because we don't want to show any preview actions for one transaction reports const filteredTransactionThreadReportActions = transactionThreadReportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED); const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; @@ -326,9 +326,9 @@ function getCombinedReportActions(reportActions: ReportAction[], transactionThre const filteredReportActions = [...reportActions, ...filteredTransactionThreadReportActions].filter((action) => { const actionType = (action as OriginalMessageIOU).originalMessage?.type ?? ''; if (isSelfDM) { - return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE && !isSentMoneyReportAction(action); + return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE; } - return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE && actionType !== CONST.IOU.REPORT_ACTION_TYPE.TRACK && !isSentMoneyReportAction(action); + return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE && actionType !== CONST.IOU.REPORT_ACTION_TYPE.TRACK; }); return getSortedReportActions(filteredReportActions, true); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5cdc9e71c54e..2eb7c6f155b6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6586,7 +6586,11 @@ function getAllAncestorReportActions(report: Report | null | undefined): Ancesto const parentReport = getReport(parentReportID); const parentReportAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? '-1'); - if (!parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction)) { + if ( + !parentReportAction || + (ReportActionsUtils.isTransactionThread(parentReportAction) && !ReportActionsUtils.isSentMoneyReportAction(parentReportAction)) || + ReportActionsUtils.isReportPreviewAction(parentReportAction) + ) { break; } @@ -6632,7 +6636,9 @@ function getAllAncestorReportActionIDs(report: Report | null | undefined, includ if ( !parentReportAction || - (!includeTransactionThread && (ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction))) + (!includeTransactionThread && + ((ReportActionsUtils.isTransactionThread(parentReportAction) && !ReportActionsUtils.isSentMoneyReportAction(parentReportAction)) || + ReportActionsUtils.isReportPreviewAction(parentReportAction))) ) { break; } diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index e4de3fa8a03f..4fad4312eccc 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -518,11 +518,10 @@ function ReportActionItem({ if ( isIOUReport(action) && action.originalMessage && - // For the pay flow, we only want to show MoneyRequestAction when sending money. When paying, we display a regular system message + // For the pay flow, we only want to show MoneyRequestAction when sending money and we're not in the combine report. Otherwise, we display a regular system message (action.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE || action.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT || - action.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK || - isSendingMoney) + action.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) ) { // There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID const iouReportID = action.originalMessage.IOUReportID ? action.originalMessage.IOUReportID.toString() : '-1'; diff --git a/src/pages/home/report/ReportActionItemParentAction.tsx b/src/pages/home/report/ReportActionItemParentAction.tsx index a5dcfcf3cc1e..4f0cf6fd4eb8 100644 --- a/src/pages/home/report/ReportActionItemParentAction.tsx +++ b/src/pages/home/report/ReportActionItemParentAction.tsx @@ -63,6 +63,7 @@ function ReportActionItemParentAction({ }: ReportActionItemParentActionProps) { const styles = useThemeStyles(); const ancestorIDs = useRef(ReportUtils.getAllAncestorReportActionIDs(report)); + const [allAncestors, setAllAncestors] = useState([]); const {isOffline} = useNetwork(); diff --git a/src/pages/home/report/ReportActionsListItemRenderer.tsx b/src/pages/home/report/ReportActionsListItemRenderer.tsx index 18118e48f7cb..9a3dc6670829 100644 --- a/src/pages/home/report/ReportActionsListItemRenderer.tsx +++ b/src/pages/home/report/ReportActionsListItemRenderer.tsx @@ -72,7 +72,9 @@ function ReportActionsListItemRenderer({ parentReportActionForTransactionThread, }: ReportActionsListItemRendererProps) { const shouldDisplayParentAction = - reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && ReportUtils.isChatThread(report) && !ReportActionsUtils.isTransactionThread(parentReportAction); + reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && + ReportUtils.isChatThread(report) && + (!ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isSentMoneyReportAction(parentReportAction)); /** * Create a lightweight ReportAction so as to keep the re-rendering as light as possible by From f23c552eec552f92b12bdbe030c2998d46aba02c Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 14 Jun 2024 13:51:10 +0700 Subject: [PATCH 2/4] fix report name of send money request action --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2eb7c6f155b6..fee0db50dd9c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2901,7 +2901,7 @@ function getTransactionReportName(reportAction: OnyxEntry Date: Mon, 17 Jun 2024 12:27:12 +0700 Subject: [PATCH 3/4] not display report actions of send money action thread in combine report --- src/libs/ReportActionsUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index b14e2497e2fa..a541ad568b0b 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -313,7 +313,7 @@ function shouldIgnoreGap(currentReportAction: ReportAction | undefined, nextRepo * transaction thread report in order to correctly display reportActions from both reports in the one-transaction report view. */ function getCombinedReportActions(reportActions: ReportAction[], transactionThreadReportActions: ReportAction[], reportID?: string): ReportAction[] { - if (isEmptyObject(transactionThreadReportActions)) { + if (isEmptyObject(transactionThreadReportActions) || reportActions.some((action) => isSentMoneyReportAction(action))) { return reportActions; } From 5b0b40a51a86d5275fd34741e01079ed67486e9e Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 24 Jun 2024 11:20:54 +0700 Subject: [PATCH 4/4] fix wrong last message text in LHN --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 49a88733be5b..82c8a3d5c21f 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -297,7 +297,7 @@ Onyx.connect({ const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]]); if (transactionThreadReportID) { const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {}); - sortedReportActions = ReportActionUtils.getCombinedReportActions(reportActionsArray, transactionThreadReportActionsArray, reportID); + sortedReportActions = ReportActionUtils.getCombinedReportActions(sortedReportActions, transactionThreadReportActionsArray, reportID); } lastReportActions[reportID] = sortedReportActions[0];