From a8bfee9708d4717c8309f250b5ace41fb1b464ee Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 28 Feb 2024 17:02:06 +0700 Subject: [PATCH 1/3] fix flag as offensive is absent --- src/libs/ReportUtils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0f8656adfa51..e6bdd019a86f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4045,7 +4045,10 @@ function chatIncludesChronos(report: OnyxEntry | EmptyObject): boolean { * - It's an ADDCOMMENT that is not an attachment */ function canFlagReportAction(reportAction: OnyxEntry, reportID: string | undefined): boolean { - const report = getReport(reportID); + let report = getReport(reportID); + if (reportAction?.childReportID && String(reportAction?.childReportID) === String(reportID)) { + report = getReport(report?.parentReportID); + } const isCurrentUserAction = reportAction?.actorAccountID === currentUserAccountID; const isOriginalMessageHaveHtml = reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || From 85f757c074c57caef6764d658f93b8800b8be65d Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 5 Mar 2024 09:18:03 +0700 Subject: [PATCH 2/3] fix add comment --- src/libs/ReportUtils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e6bdd019a86f..29906f207673 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4046,7 +4046,9 @@ function chatIncludesChronos(report: OnyxEntry | EmptyObject): boolean { */ function canFlagReportAction(reportAction: OnyxEntry, reportID: string | undefined): boolean { let report = getReport(reportID); - if (reportAction?.childReportID && String(reportAction?.childReportID) === String(reportID)) { + // If the childReportID exists in reportAction and is equal to the reportID, + // the report action being evaluated is the parent report action in a thread, and we should get the parent report to evaluate instead. + if (reportAction?.childReportID?.toString() === reportID?.toString()) { report = getReport(report?.parentReportID); } const isCurrentUserAction = reportAction?.actorAccountID === currentUserAccountID; From 0a4ced189735cf779271540a3f6bf9a57aeff4a3 Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Thu, 7 Mar 2024 20:48:13 +0700 Subject: [PATCH 3/3] fix: update comment Co-authored-by: Youssef Lourayad --- src/libs/ReportUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 772463be8592..46c678ed2eb6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4139,6 +4139,7 @@ function chatIncludesChronos(report: OnyxEntry | EmptyObject): boolean { */ function canFlagReportAction(reportAction: OnyxEntry, reportID: string | undefined): boolean { let report = getReport(reportID); + // If the childReportID exists in reportAction and is equal to the reportID, // the report action being evaluated is the parent report action in a thread, and we should get the parent report to evaluate instead. if (reportAction?.childReportID?.toString() === reportID?.toString()) {