From 8c81ca2729cd9f09d8671f628aef856f7a0954bd Mon Sep 17 00:00:00 2001 From: Kevin Cook Date: Thu, 23 May 2024 09:08:25 -0600 Subject: [PATCH 1/4] Temporarily allow report preview actions to be thread ancestors in order to more easily demonstrate that issue 41519 has been fixed. --- src/libs/ReportUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b8e4c448fdc2..085dca716b2e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6329,7 +6329,8 @@ function getAllAncestorReportActions(report: Report | null | undefined): Ancesto const parentReport = getReport(parentReportID); const parentReportAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? '0'); - if (!parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction)) { + //if (!parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction)) { + if (!parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction)) { break; } From 4368266929f59d2cf4062b7416ee26a509436999 Mon Sep 17 00:00:00 2001 From: Kevin Cook Date: Thu, 23 May 2024 09:19:59 -0600 Subject: [PATCH 2/4] Fix issue. Each ancestor references the report and the action belonging to that report which is parent of its child report. --- src/libs/ReportUtils.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 085dca716b2e..6846e4122cdc 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6322,34 +6322,24 @@ function getAllAncestorReportActions(report: Report | null | undefined): Ancesto let parentReportID = report.parentReportID; let parentReportActionID = report.parentReportActionID; - // Store the child of parent report - let currentReport = report; - while (parentReportID) { const parentReport = getReport(parentReportID); const parentReportAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? '0'); //if (!parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction)) { - if (!parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction)) { + if (!parentReport || !parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction)) { break; } const isParentReportActionUnread = ReportActionsUtils.isCurrentActionUnread(parentReport ?? {}, parentReportAction); allAncestors.push({ - report: currentReport, + report: parentReport, reportAction: parentReportAction, shouldDisplayNewMarker: isParentReportActionUnread, }); - if (!parentReport) { - break; - } - parentReportID = parentReport?.parentReportID; parentReportActionID = parentReport?.parentReportActionID; - if (!isEmptyObject(parentReport)) { - currentReport = parentReport; - } } return allAncestors.reverse(); From 1f345ebd179b3bd9ffee4ae2fa0ae5944e7e8ba5 Mon Sep 17 00:00:00 2001 From: Kevin Cook Date: Thu, 23 May 2024 12:13:38 -0600 Subject: [PATCH 3/4] End temporary change allowing report preview actions to be thread ancestors. --- src/libs/ReportUtils.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6846e4122cdc..eb52f9057b99 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6326,8 +6326,7 @@ function getAllAncestorReportActions(report: Report | null | undefined): Ancesto const parentReport = getReport(parentReportID); const parentReportAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? '0'); - //if (!parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction)) { - if (!parentReport || !parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction)) { + if (!parentReport || !parentReportAction || ReportActionsUtils.isTransactionThread(parentReportAction) || ReportActionsUtils.isReportPreviewAction(parentReportAction)) { break; } From b29137bf85cd7537ea80c9d791450113c246b82c Mon Sep 17 00:00:00 2001 From: Kevin Cook Date: Thu, 23 May 2024 14:42:52 -0600 Subject: [PATCH 4/4] Fix incorrect unit test --- tests/unit/ReportUtilsTest.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index d0005c59d39a..b8066cb4b95d 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -819,10 +819,10 @@ describe('ReportUtils', () => { it('should return correctly all ancestors of a thread report', () => { const resultAncestors = [ - {report: reports[1], reportAction: reportActions[0], shouldDisplayNewMarker: false}, - {report: reports[2], reportAction: reportActions[1], shouldDisplayNewMarker: false}, - {report: reports[3], reportAction: reportActions[2], shouldDisplayNewMarker: false}, - {report: reports[4], reportAction: reportActions[3], shouldDisplayNewMarker: false}, + {report: reports[0], reportAction: reportActions[0], shouldDisplayNewMarker: false}, + {report: reports[1], reportAction: reportActions[1], shouldDisplayNewMarker: false}, + {report: reports[2], reportAction: reportActions[2], shouldDisplayNewMarker: false}, + {report: reports[3], reportAction: reportActions[3], shouldDisplayNewMarker: false}, ]; expect(ReportUtils.getAllAncestorReportActions(reports[4])).toEqual(resultAncestors);