Skip to content

Commit d136101

Browse files
Merge pull request #43742 from nkdengineer/fix/41645
fix: display thread of send money request as normal thread
2 parents 24b7c48 + d68624b commit d136101

5 files changed

+21
-11
lines changed

src/libs/OptionsListUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Onyx.connect({
297297
const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]]);
298298
if (transactionThreadReportID) {
299299
const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {});
300-
sortedReportActions = ReportActionUtils.getCombinedReportActions(reportActionsArray, transactionThreadReportID, transactionThreadReportActionsArray, reportID);
300+
sortedReportActions = ReportActionUtils.getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, reportID);
301301
}
302302

303303
lastReportActions[reportID] = sortedReportActions[0];

src/libs/ReportActionsUtils.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,14 @@ function getCombinedReportActions(
383383
transactionThreadReportActions: ReportAction[],
384384
reportID?: string,
385385
): ReportAction[] {
386-
if (_.isEmpty(transactionThreadReportID)) {
386+
const isSentMoneyReport = reportActions.some((action) => isSentMoneyReportAction(action));
387+
388+
// We don't want to combine report actions of transaction thread in iou report of send money request because we display the transaction report of send money request as a normal thread
389+
if (_.isEmpty(transactionThreadReportID) || isSentMoneyReport) {
387390
return reportActions;
388391
}
389392

390-
// Filter out the created action from the transaction thread report actions, since we already have the parent report's created action in `reportActions`
393+
// Filter out request money actions because we don't want to show any preview actions for one transaction reports
391394
const filteredTransactionThreadReportActions = transactionThreadReportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED);
392395
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
393396
const isSelfDM = report?.chatType === CONST.REPORT.CHAT_TYPE.SELF_DM;
@@ -398,9 +401,9 @@ function getCombinedReportActions(
398401
}
399402
const actionType = getOriginalMessage(action)?.type ?? '';
400403
if (isSelfDM) {
401-
return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE && !isSentMoneyReportAction(action);
404+
return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE;
402405
}
403-
return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE && actionType !== CONST.IOU.REPORT_ACTION_TYPE.TRACK && !isSentMoneyReportAction(action);
406+
return actionType !== CONST.IOU.REPORT_ACTION_TYPE.CREATE && actionType !== CONST.IOU.REPORT_ACTION_TYPE.TRACK;
404407
});
405408

406409
return getSortedReportActions(filteredReportActions, true);

src/libs/ReportUtils.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,7 @@ function getTransactionReportName(reportAction: OnyxEntry<ReportAction | Optimis
29182918
return Localize.translateLocal('iou.threadTrackReportName', {formattedAmount, comment});
29192919
}
29202920
if (ReportActionsUtils.isSentMoneyReportAction(reportAction)) {
2921-
return Localize.translateLocal('iou.threadPaySomeoneReportName', {formattedAmount, comment});
2921+
return getIOUReportActionDisplayMessage(reportAction as ReportAction, transaction);
29222922
}
29232923
return Localize.translateLocal('iou.threadExpenseReportName', {formattedAmount, comment});
29242924
}
@@ -6647,7 +6647,11 @@ function getAllAncestorReportActions(report: Report | null | undefined): Ancesto
66476647
const parentReport = getReportOrDraftReport(parentReportID);
66486648
const parentReportAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? '-1');
66496649

6650-
if (!parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction)) {
6650+
if (
6651+
!parentReportAction ||
6652+
(ReportActionsUtils.isTransactionThread(parentReportAction) && !ReportActionsUtils.isSentMoneyReportAction(parentReportAction)) ||
6653+
ReportActionsUtils.isReportPreviewAction(parentReportAction)
6654+
) {
66516655
break;
66526656
}
66536657

@@ -6693,7 +6697,9 @@ function getAllAncestorReportActionIDs(report: Report | null | undefined, includ
66936697

66946698
if (
66956699
!parentReportAction ||
6696-
(!includeTransactionThread && (ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction)))
6700+
(!includeTransactionThread &&
6701+
((ReportActionsUtils.isTransactionThread(parentReportAction) && !ReportActionsUtils.isSentMoneyReportAction(parentReportAction)) ||
6702+
ReportActionsUtils.isReportPreviewAction(parentReportAction)))
66976703
) {
66986704
break;
66996705
}

src/pages/home/report/ReportActionItem.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,7 @@ function ReportActionItem({
500500
// For the pay flow, we only want to show MoneyRequestAction when sending money. When paying, we display a regular system message
501501
(ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE ||
502502
ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT ||
503-
ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK ||
504-
isSendingMoney)
503+
ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK)
505504
) {
506505
// There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID
507506
const iouReportID = ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ? ReportActionsUtils.getOriginalMessage(action)?.IOUReportID?.toString() ?? '-1' : '-1';

src/pages/home/report/ReportActionsListItemRenderer.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ function ReportActionsListItemRenderer({
7272
parentReportActionForTransactionThread,
7373
}: ReportActionsListItemRendererProps) {
7474
const shouldDisplayParentAction =
75-
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED && ReportUtils.isChatThread(report) && !ReportActionsUtils.isTransactionThread(parentReportAction);
75+
reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED &&
76+
ReportUtils.isChatThread(report) &&
77+
(!ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isSentMoneyReportAction(parentReportAction));
7678

7779
/**
7880
* Create a lightweight ReportAction so as to keep the re-rendering as light as possible by

0 commit comments

Comments
 (0)