From 846d45580a2cd938fddf76b3645c4229d8f872e5 Mon Sep 17 00:00:00 2001 From: Ben Limpich Date: Wed, 31 Jan 2024 15:06:39 -0800 Subject: [PATCH 1/3] fix base url not showing for leave messages and refactor this function so this doesn't happen again and so this function is more readable --- src/libs/ReportActionsUtils.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 453d69e3041c..e6aa77d4466a 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -415,29 +415,23 @@ function shouldReportActionBeVisibleAsLastAction(reportAction: OnyxEntry(Object.values(CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG)); - if ( - !reportAction || - (reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.INVITE_TO_ROOM && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG.REMOVE_FROM_ROOM) - ) { - return reportAction; - } - if (!reportAction.message) { + if (!reportAction?.message || !policyChangeActions.has(reportAction?.actionName)) { return reportAction; } + const updatedReportAction = _.clone(reportAction); + if (!updatedReportAction.message) { return updatedReportAction; } + updatedReportAction.message[0].html = reportAction.message[0].html?.replace('%baseURL', environmentURL); + return updatedReportAction; } -/** - */ function getLastVisibleAction(reportID: string, actionsToMerge: ReportActions = {}): OnyxEntry { const reportActions = Object.values(fastMerge(allReportActions?.[reportID] ?? {}, actionsToMerge, true)); const visibleReportActions = Object.values(reportActions ?? {}).filter((action) => shouldReportActionBeVisibleAsLastAction(action)); From fdee9b26481d0785f276a1d715c020a14a093e0a Mon Sep 17 00:00:00 2001 From: Ben Limpich Date: Wed, 31 Jan 2024 15:58:39 -0800 Subject: [PATCH 2/3] respond to feedback --- src/libs/ReportActionsUtils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index e6aa77d4466a..dfa437a78c8f 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -39,6 +39,8 @@ type MemberChangeMessageRoomReferenceElement = { type MemberChangeMessageElement = MessageTextElement | MemberChangeMessageUserMentionElement | MemberChangeMessageRoomReferenceElement; +const policyChangeActionsSet = new Set(Object.values(CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG)); + const allReports: OnyxCollection = {}; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT, @@ -411,13 +413,11 @@ function shouldReportActionBeVisibleAsLastAction(reportAction: OnyxEntry(Object.values(CONST.REPORT.ACTIONS.TYPE.POLICYCHANGELOG)); - - if (!reportAction?.message || !policyChangeActions.has(reportAction?.actionName)) { + if (!reportAction?.message || !policyChangeActionsSet.has(reportAction?.actionName)) { return reportAction; } From 8bd87b2e86ce4015a6ce4796c69eb766f80389a8 Mon Sep 17 00:00:00 2001 From: Ben Limpich Date: Wed, 31 Jan 2024 16:09:23 -0800 Subject: [PATCH 3/3] rename function --- src/libs/ReportActionsUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index dfa437a78c8f..fd24f8d6558b 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -416,7 +416,7 @@ function shouldReportActionBeVisibleAsLastAction(reportAction: OnyxEntry shouldReportActionBeVisible(reportAction, key)) .map((entry) => entry[1]); - const baseURLAdjustedReportActions = filteredReportActions.map((reportAction) => replaceBaseURL(reportAction)); + const baseURLAdjustedReportActions = filteredReportActions.map((reportAction) => replaceBaseURLInPolicyChangeLogAction(reportAction)); return getSortedReportActions(baseURLAdjustedReportActions, true, shouldMarkTheFirstItemAsNewest); }