From 846d45580a2cd938fddf76b3645c4229d8f872e5 Mon Sep 17 00:00:00 2001 From: Ben Limpich Date: Wed, 31 Jan 2024 15:06:39 -0800 Subject: [PATCH] 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));