Skip to content

Commit

Permalink
Merge pull request #44529 from callstack-internal/One-expense-report-…
Browse files Browse the repository at this point in the history
…old-chat-messages-stays-in-chat

One-expense-report old chat messages stays in chat
  • Loading branch information
puneetlath authored Jul 7, 2024
2 parents ee4e6ba + 580243d commit b0947e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,14 @@ function getSortedReportActions(reportActions: ReportAction[] | null, shouldSort
return sortedActions;
}

/**
* Returns filtered list for one transaction view as we don't want to display IOU action type in the one-transaction view
* Separated it from getCombinedReportActions, so it can be reused
*/
function getFilteredForOneTransactionView(reportActions: ReportAction[]): ReportAction[] {
return reportActions.filter((action) => !isSentMoneyReportAction(action));
}

/**
* Returns a sorted and filtered list of report actions from a report and it's associated child
* transaction thread report in order to correctly display reportActions from both reports in the one-transaction report view.
Expand Down Expand Up @@ -1477,6 +1485,7 @@ export {
getTextFromHtml,
isTripPreview,
getIOUActionForReportID,
getFilteredForOneTransactionView,
};

export type {LastVisibleMessage};
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemContentCreated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function ReportActionItemContentCreated({contextValue, parentReportAction, trans
<OfflineWithFeedback pendingAction={action.pendingAction}>
{transactionThreadReport && !isEmptyObject(transactionThreadReport) ? (
<>
{transactionCurrency !== report.currency && (
{!!transaction && transactionCurrency !== report.currency && (
<>
<MoneyReportView
report={report}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ function ReportActionsView({
createdAction.pendingAction = CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE;
}

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

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

0 comments on commit b0947e0

Please sign in to comment.