Skip to content

Commit

Permalink
Merge pull request #44946 from dominictb/fix/42795-submit-exp
Browse files Browse the repository at this point in the history
fix: update logic of filtering created actions from transaction thread report
  • Loading branch information
stitesExpensify authored Jul 15, 2024
2 parents cf34d87 + 07816cf commit 4778fcc
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,25 @@ function getCombinedReportActions(
return 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);
// Usually, we filter out the created action from the transaction thread report actions, since we already have the parent report's created action in `reportActions`
// However, in the case of moving track expense, the transaction thread will be created first in a track expense, thus we should keep the CREATED of the transaction thread and filter out CREATED action of the IOU
// This makes sense because in a combined report action list, whichever CREATED is first need to be retained.
const transactionThreadCreatedAction = transactionThreadReportActions?.find((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED);
const parentReportCreatedAction = reportActions?.find((action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED);

let filteredTransactionThreadReportActions = transactionThreadReportActions;
let filteredParentReportActions = reportActions;

if (transactionThreadCreatedAction && parentReportCreatedAction && transactionThreadCreatedAction.created > parentReportCreatedAction.created) {
filteredTransactionThreadReportActions = transactionThreadReportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED);
} else {
filteredParentReportActions = reportActions?.filter((action) => action.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED);
}

const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const isSelfDM = report?.chatType === CONST.REPORT.CHAT_TYPE.SELF_DM;
// Filter out request and send money request actions because we don't want to show any preview actions for one transaction reports
const filteredReportActions = [...reportActions, ...filteredTransactionThreadReportActions].filter((action) => {
const filteredReportActions = [...filteredParentReportActions, ...filteredTransactionThreadReportActions].filter((action) => {
if (!isMoneyRequestAction(action)) {
return true;
}
Expand Down

0 comments on commit 4778fcc

Please sign in to comment.