diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ee8e221e5aba..5aeaf7c2aa3c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1463,10 +1463,10 @@ function isOneTransactionReport(reportID: string): boolean { /** * Checks if a report is a transaction thread associated with a report that has only one transaction */ -function isOneTransactionThread(reportID: string, parentReportID: string): boolean { +function isOneTransactionThread(reportID: string, parentReportID: string, threadParentReportAction: OnyxEntry): boolean { const parentReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`] ?? ([] as ReportAction[]); const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(parentReportID, parentReportActions); - return reportID === transactionThreadReportID; + return reportID === transactionThreadReportID && !ReportActionsUtils.isSentMoneyReportAction(threadParentReportAction); } /** @@ -5410,6 +5410,8 @@ function shouldReportBeInOptionList({ // This can also happen for anyone accessing a public room or archived room for which they don't have access to the underlying policy. // Optionally exclude reports that do not belong to currently active workspace + const parentReportAction = ReportActionsUtils.getParentReportAction(report); + if ( !report?.reportID || !report?.type || @@ -5440,7 +5442,7 @@ function shouldReportBeInOptionList({ } // If this is a transaction thread associated with a report that only has one transaction, omit it - if (isOneTransactionThread(report.reportID, report.parentReportID ?? '-1')) { + if (isOneTransactionThread(report.reportID, report.parentReportID ?? '-1', parentReportAction)) { return false; } @@ -5509,8 +5511,6 @@ function shouldReportBeInOptionList({ return false; } - const parentReportAction = ReportActionsUtils.getParentReportAction(report); - // Hide chat threads where the parent message is pending removal if ( !isEmptyObject(parentReportAction) && diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 4f227e04482a..c7d3686289a8 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -88,13 +88,14 @@ function getOrderedReportIDs( return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; + const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); const doesReportHaveViolations = OptionsListUtils.shouldShowViolations(report, betas ?? [], transactionViolations); const isHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; const isFocused = report.reportID === currentReportId; const allReportErrors = OptionsListUtils.getAllReportErrors(report, reportActions) ?? {}; const hasErrorsOtherThanFailedReceipt = doesReportHaveViolations || Object.values(allReportErrors).some((error) => error?.[0] !== Localize.translateLocal('iou.error.genericSmartscanFailureMessage')); - if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0')) { + if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0', parentReportAction)) { return; } if (hasErrorsOtherThanFailedReceipt) {