Skip to content

Commit

Permalink
fix base url not showing for leave messages
Browse files Browse the repository at this point in the history
and refactor this function so this doesn't happen again and so this
function is more readable
  • Loading branch information
blimpich committed Jan 31, 2024
1 parent ed95bc0 commit 846d455
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,29 +415,23 @@ function shouldReportActionBeVisibleAsLastAction(reportAction: OnyxEntry<ReportA
* which includes a baseURL placeholder that's replaced in the client.
*/
function replaceBaseURL(reportAction: ReportAction): ReportAction {
if (!reportAction) {
return reportAction;
}
const policyChangeActions = new Set<string>(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<ReportAction> {
const reportActions = Object.values(fastMerge(allReportActions?.[reportID] ?? {}, actionsToMerge, true));
const visibleReportActions = Object.values(reportActions ?? {}).filter((action) => shouldReportActionBeVisibleAsLastAction(action));
Expand Down

0 comments on commit 846d455

Please sign in to comment.