From 1a5cb787f587f29d391926cfa9f63c0193e91532 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 28 Jun 2024 15:54:36 +0800 Subject: [PATCH 1/4] don't hide one transaction thread if it's a paid money thread --- src/libs/ReportUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ae1fdda70200..69d072705a85 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5400,6 +5400,7 @@ function shouldReportBeInOptionList({ // Optionally exclude reports that do not belong to currently active workspace const participantAccountIDs = Object.keys(report?.participants ?? {}).map(Number); + const parentReportAction = ReportActionsUtils.getParentReportAction(report); if ( !report?.reportID || @@ -5431,7 +5432,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') && !ReportActionsUtils.isSentMoneyReportAction(parentReportAction)) { return false; } @@ -5495,7 +5496,6 @@ function shouldReportBeInOptionList({ if (isSelfDM(report)) { return includeSelfDM; } - const parentReportAction = ReportActionsUtils.getParentReportAction(report); // Hide chat threads where the parent message is pending removal if ( From 5e9225eb96c86a8b1327435cc11086437029b015 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 2 Jul 2024 16:24:30 +0800 Subject: [PATCH 2/4] update isOneTransactionThread to return false for sent money action --- src/libs/ReportUtils.ts | 6 +++--- src/libs/SidebarUtils.ts | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8466e35a6814..6b6ab6010fa0 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1455,10 +1455,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); } /** @@ -5458,7 +5458,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') && !ReportActionsUtils.isSentMoneyReportAction(parentReportAction)) { + if (isOneTransactionThread(report.reportID, report.parentReportID ?? '-1', parentReportAction)) { return false; } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index b7d365a103ae..8d619b983cf9 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -88,13 +88,16 @@ function getOrderedReportIDs( return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; + const parentReportAction = report.parentReportID && report.parentReportActionID + ? allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.find((reportAction) => reportAction.reportActionID === report.parentReportActionID) + : undefined; 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 as ReportAction)) { return; } if (hasErrorsOtherThanFailedReceipt) { From f0e671335c7ada9c1a4b000a5bc66599640e91b0 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 8 Jul 2024 13:46:32 +0800 Subject: [PATCH 3/4] prettier --- src/libs/SidebarUtils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 2049c18e3279..954d5f189fad 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -88,9 +88,10 @@ function getOrderedReportIDs( return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; - const parentReportAction = report.parentReportID && report.parentReportActionID - ? allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.find((reportAction) => reportAction.reportActionID === report.parentReportActionID) - : undefined; + const parentReportAction = + report.parentReportID && report.parentReportActionID + ? allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.find((reportAction) => reportAction.reportActionID === report.parentReportActionID) + : undefined; const doesReportHaveViolations = OptionsListUtils.shouldShowViolations(report, betas ?? [], transactionViolations); const isHidden = report.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; const isFocused = report.reportID === currentReportId; From 5b7cf3744e20d3c08495601d5319e2c632fab09f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 8 Jul 2024 19:43:53 +0800 Subject: [PATCH 4/4] use getReportAction --- src/libs/SidebarUtils.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 7912be11428a..c7d3686289a8 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -88,17 +88,14 @@ function getOrderedReportIDs( return; } const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`] ?? {}; - const parentReportAction = - report.parentReportID && report.parentReportActionID - ? allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`]?.find((reportAction) => reportAction.reportActionID === report.parentReportActionID) - : undefined; + 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', parentReportAction as ReportAction)) { + if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0', parentReportAction)) { return; } if (hasErrorsOtherThanFailedReceipt) {