Skip to content

Commit b0947e0

Browse files
authored
Merge pull request Expensify#44529 from callstack-internal/One-expense-report-old-chat-messages-stays-in-chat
One-expense-report old chat messages stays in chat
2 parents ee4e6ba + 580243d commit b0947e0

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/libs/ReportActionsUtils.ts

+9
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,14 @@ function getSortedReportActions(reportActions: ReportAction[] | null, shouldSort
351351
return sortedActions;
352352
}
353353

354+
/**
355+
* Returns filtered list for one transaction view as we don't want to display IOU action type in the one-transaction view
356+
* Separated it from getCombinedReportActions, so it can be reused
357+
*/
358+
function getFilteredForOneTransactionView(reportActions: ReportAction[]): ReportAction[] {
359+
return reportActions.filter((action) => !isSentMoneyReportAction(action));
360+
}
361+
354362
/**
355363
* Returns a sorted and filtered list of report actions from a report and it's associated child
356364
* transaction thread report in order to correctly display reportActions from both reports in the one-transaction report view.
@@ -1477,6 +1485,7 @@ export {
14771485
getTextFromHtml,
14781486
isTripPreview,
14791487
getIOUActionForReportID,
1488+
getFilteredForOneTransactionView,
14801489
};
14811490

14821491
export type {LastVisibleMessage};

src/pages/home/report/ReportActionItemContentCreated.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function ReportActionItemContentCreated({contextValue, parentReportAction, trans
149149
<OfflineWithFeedback pendingAction={action.pendingAction}>
150150
{transactionThreadReport && !isEmptyObject(transactionThreadReport) ? (
151151
<>
152-
{transactionCurrency !== report.currency && (
152+
{!!transaction && transactionCurrency !== report.currency && (
153153
<>
154154
<MoneyReportView
155155
report={report}

src/pages/home/report/ReportActionsView.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ function ReportActionsView({
213213
createdAction.pendingAction = CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE;
214214
}
215215

216-
return [...actions, createdAction];
216+
// moneyRequestActions.length === 1 indicates that we have one-transaction report and we don't want to display additonal IOU action
217+
return moneyRequestActions.length === 1 ? ReportActionsUtils.getFilteredForOneTransactionView([...actions, createdAction]) : [...actions, createdAction];
217218
}, [allReportActions, report, transactionThreadReport]);
218219

219220
// Get a sorted array of reportActions for both the current report and the transaction thread report associated with this report (if there is one)

0 commit comments

Comments
 (0)