From c23def12232b5847272e0bb3790af5b1910bb27e Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Thu, 18 Apr 2024 18:09:24 -0300 Subject: [PATCH 1/8] checking if room is from a policy in case the policy type is emtpy --- .../HTMLRenderers/MentionReportRenderer.tsx | 4 +++- .../home/report/ReportActionCompose/ReportActionCompose.tsx | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx index 52377fa20b4d..738987df538b 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx @@ -63,7 +63,9 @@ function MentionReportRenderer({style, tnode, TDefaultRenderer, reports, ...defa const currentReportID = useCurrentReportID(); const currentReport = getReport(currentReportID?.currentReportID); - const isGroupPolicyReport = useMemo(() => (currentReport && !isEmptyObject(currentReport) ? ReportUtils.isGroupPolicy(currentReport) : false), [currentReport]); + + // When we invite someone to a room they don't have the policy type, but we still want them to be able to mention other reports they are members of, so we also check the reportType in case the policyType was empty. + const isGroupPolicyReport = useMemo(() => (currentReport && !isEmptyObject(currentReport) ? (ReportUtils.isGroupPolicy(currentReport) || ReportUtils.isChatRoom(currentReport)) : false), [currentReport]); const mentionDetails = getMentionDetails(htmlAttributeReportID, currentReport, reports, tnode); if (!mentionDetails) { diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index b9b9025bb02b..1a996498c4c4 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -342,7 +342,8 @@ function ReportActionCompose({ [], ); - const isGroupPolicyReport = useMemo(() => ReportUtils.isGroupPolicy(report), [report]); + // When we invite someone to a room they don't have the policy type, but we still want them to be able to mention other reports they are members of, so we also check the reportType in case the policyType was empty. + const isGroupPolicyReport = useMemo(() => (ReportUtils.isGroupPolicy(report) || ReportUtils.isChatRoom(report)), [report]); const reportRecipientAcountIDs = ReportUtils.getReportRecipientAccountIDs(report, currentUserPersonalDetails.accountID); const reportRecipient = personalDetails[reportRecipientAcountIDs[0]]; const shouldUseFocusedColor = !isBlockedFromConcierge && !disabled && isFocused; From d99c451ec0034cae9a80057af97b1f394df65e3c Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Thu, 18 Apr 2024 18:11:45 -0300 Subject: [PATCH 2/8] better comment in rendere --- .../HTMLRenderers/MentionReportRenderer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx index 738987df538b..5341f4708a74 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx @@ -63,8 +63,8 @@ function MentionReportRenderer({style, tnode, TDefaultRenderer, reports, ...defa const currentReportID = useCurrentReportID(); const currentReport = getReport(currentReportID?.currentReportID); - - // When we invite someone to a room they don't have the policy type, but we still want them to be able to mention other reports they are members of, so we also check the reportType in case the policyType was empty. + + // When we invite someone to a room they don't have the policy type, but we still want them to be able see and click on report mentions, so we also check the reportType in case the policyType was empty. const isGroupPolicyReport = useMemo(() => (currentReport && !isEmptyObject(currentReport) ? (ReportUtils.isGroupPolicy(currentReport) || ReportUtils.isChatRoom(currentReport)) : false), [currentReport]); const mentionDetails = getMentionDetails(htmlAttributeReportID, currentReport, reports, tnode); From 2936567146d0b172c68c20221e45c2e71b341b03 Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Thu, 18 Apr 2024 18:27:58 -0300 Subject: [PATCH 3/8] prettier --- .../HTMLRenderers/MentionReportRenderer.tsx | 5 ++++- .../home/report/ReportActionCompose/ReportActionCompose.tsx | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx index 5341f4708a74..d1710505c42c 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx @@ -65,7 +65,10 @@ function MentionReportRenderer({style, tnode, TDefaultRenderer, reports, ...defa const currentReport = getReport(currentReportID?.currentReportID); // When we invite someone to a room they don't have the policy type, but we still want them to be able see and click on report mentions, so we also check the reportType in case the policyType was empty. - const isGroupPolicyReport = useMemo(() => (currentReport && !isEmptyObject(currentReport) ? (ReportUtils.isGroupPolicy(currentReport) || ReportUtils.isChatRoom(currentReport)) : false), [currentReport]); + const isGroupPolicyReport = useMemo( + () => (currentReport && !isEmptyObject(currentReport) ? ReportUtils.isGroupPolicy(currentReport) || ReportUtils.isChatRoom(currentReport) : false), + [currentReport], + ); const mentionDetails = getMentionDetails(htmlAttributeReportID, currentReport, reports, tnode); if (!mentionDetails) { diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index 1a996498c4c4..64038ce19852 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -343,7 +343,7 @@ function ReportActionCompose({ ); // When we invite someone to a room they don't have the policy type, but we still want them to be able to mention other reports they are members of, so we also check the reportType in case the policyType was empty. - const isGroupPolicyReport = useMemo(() => (ReportUtils.isGroupPolicy(report) || ReportUtils.isChatRoom(report)), [report]); + const isGroupPolicyReport = useMemo(() => ReportUtils.isGroupPolicy(report) || ReportUtils.isChatRoom(report), [report]); const reportRecipientAcountIDs = ReportUtils.getReportRecipientAccountIDs(report, currentUserPersonalDetails.accountID); const reportRecipient = personalDetails[reportRecipientAcountIDs[0]]; const shouldUseFocusedColor = !isBlockedFromConcierge && !disabled && isFocused; From 2e085f3cadee326deb24fa7d2c97391092278e0b Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Fri, 19 Apr 2024 14:08:57 -0300 Subject: [PATCH 4/8] checking only the policyID instead of checking types --- .../HTMLRenderers/MentionReportRenderer.tsx | 4 ++-- .../home/report/ReportActionCompose/ReportActionCompose.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx index d1710505c42c..53828e1690fa 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx @@ -64,9 +64,9 @@ function MentionReportRenderer({style, tnode, TDefaultRenderer, reports, ...defa const currentReportID = useCurrentReportID(); const currentReport = getReport(currentReportID?.currentReportID); - // When we invite someone to a room they don't have the policy type, but we still want them to be able see and click on report mentions, so we also check the reportType in case the policyType was empty. + // When we invite someone to a room they don't have the policy object, but we still want them to be able to see and click on report mentions, so we only check if the policyID in the report is from a workspace const isGroupPolicyReport = useMemo( - () => (currentReport && !isEmptyObject(currentReport) ? ReportUtils.isGroupPolicy(currentReport) || ReportUtils.isChatRoom(currentReport) : false), + () => (currentReport && !isEmptyObject(currentReport) ? !!currentReport.policyID && currentReport.policyID !== CONST.POLICY.ID_FAKE : false), [currentReport], ); diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index 64038ce19852..75d0c703b5b1 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -342,8 +342,8 @@ function ReportActionCompose({ [], ); - // When we invite someone to a room they don't have the policy type, but we still want them to be able to mention other reports they are members of, so we also check the reportType in case the policyType was empty. - const isGroupPolicyReport = useMemo(() => ReportUtils.isGroupPolicy(report) || ReportUtils.isChatRoom(report), [report]); + // When we invite someone to a room they don't have the policy object, but we still want them to be able to mention other reports they are members of, so we only check if the policyID in the report is from a workspace + const isGroupPolicyReport = useMemo(() => !!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE, [report]); const reportRecipientAcountIDs = ReportUtils.getReportRecipientAccountIDs(report, currentUserPersonalDetails.accountID); const reportRecipient = personalDetails[reportRecipientAcountIDs[0]]; const shouldUseFocusedColor = !isBlockedFromConcierge && !disabled && isFocused; From 6caa78cda2c71d805647936a5aed4ed7a05ef7c9 Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Fri, 19 Apr 2024 14:39:45 -0300 Subject: [PATCH 5/8] Removed unused import --- .../HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx index 53828e1690fa..6dd7e0b0666b 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx @@ -11,7 +11,6 @@ import useCurrentReportID from '@hooks/useCurrentReportID'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import {getReport} from '@libs/ReportUtils'; -import * as ReportUtils from '@libs/ReportUtils'; import Navigation from '@navigation/Navigation'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; From 23497bf11664532f62065caf20f2d584124e8e39 Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Fri, 19 Apr 2024 22:50:04 -0300 Subject: [PATCH 6/8] Using the reportID from the HTML in case the report doesn't have a reportID --- .../HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx index 6dd7e0b0666b..9d8d82ff5042 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx @@ -36,7 +36,7 @@ const getMentionDetails = (htmlAttributeReportID: string, currentReport: OnyxEnt if (!isEmpty(htmlAttributeReportID)) { const report = getReport(htmlAttributeReportID); - reportID = report?.reportID ?? undefined; + reportID = report?.reportID ?? htmlAttributeReportID; mentionDisplayText = removeLeadingLTRAndHash(report?.reportName ?? report?.displayName ?? htmlAttributeReportID); // Get mention details from name inside tnode } else if ('data' in tnode && !isEmptyObject(tnode.data)) { From 2126f531db72d2a4bfe51a417961e207b09b40e9 Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Mon, 22 Apr 2024 10:51:24 -0300 Subject: [PATCH 7/8] simpler condition --- .../HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx index 9d8d82ff5042..b36ee89acc02 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx @@ -65,7 +65,7 @@ function MentionReportRenderer({style, tnode, TDefaultRenderer, reports, ...defa // When we invite someone to a room they don't have the policy object, but we still want them to be able to see and click on report mentions, so we only check if the policyID in the report is from a workspace const isGroupPolicyReport = useMemo( - () => (currentReport && !isEmptyObject(currentReport) ? !!currentReport.policyID && currentReport.policyID !== CONST.POLICY.ID_FAKE : false), + () => currentReport && !isEmptyObject(currentReport) && !!currentReport.policyID && currentReport.policyID !== CONST.POLICY.ID_FAKE, [currentReport], ); From 8c1633407dde167c79814bd2b96d3e8050201b83 Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Mon, 22 Apr 2024 10:58:49 -0300 Subject: [PATCH 8/8] prettier --- .../HTMLRenderers/MentionReportRenderer.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx index b36ee89acc02..345bd338f365 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer.tsx @@ -64,10 +64,7 @@ function MentionReportRenderer({style, tnode, TDefaultRenderer, reports, ...defa const currentReport = getReport(currentReportID?.currentReportID); // When we invite someone to a room they don't have the policy object, but we still want them to be able to see and click on report mentions, so we only check if the policyID in the report is from a workspace - const isGroupPolicyReport = useMemo( - () => currentReport && !isEmptyObject(currentReport) && !!currentReport.policyID && currentReport.policyID !== CONST.POLICY.ID_FAKE, - [currentReport], - ); + const isGroupPolicyReport = useMemo(() => currentReport && !isEmptyObject(currentReport) && !!currentReport.policyID && currentReport.policyID !== CONST.POLICY.ID_FAKE, [currentReport]); const mentionDetails = getMentionDetails(htmlAttributeReportID, currentReport, reports, tnode); if (!mentionDetails) {