From 56a274098634a78013a6101ac77fdb5e3d054046 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Tue, 3 Sep 2024 00:30:19 +0200 Subject: [PATCH] Fix system update messages for tags --- src/libs/ReportActionsUtils.ts | 15 +++++++++++++++ src/libs/SidebarUtils.ts | 2 +- src/pages/home/report/ReportActionItem.tsx | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 4d126cf9cbf4a..57896fa602e79 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -957,6 +957,20 @@ function isTaskAction(reportAction: OnyxEntry): boolean { ); } +/** + * @param actionName - The name of the action + * @returns - Whether the action is a tag modification action + * */ +function isTagModificationAction(actionName: string): boolean { + return ( + actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG || + actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_ENABLED || + actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_NAME || + actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAG || + actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG + ); +} + // Get all IOU report actions for the report. const iouRequestTypes = new Set>([ CONST.IOU.REPORT_ACTION_TYPE.CREATE, @@ -1741,6 +1755,7 @@ export { isApprovedAction, isForwardedAction, isWhisperActionTargetedToOthers, + isTagModificationAction, shouldHideNewMarker, shouldReportActionBeVisible, shouldReportActionBeVisibleAsLastAction, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index dedd608ce77de..c392f8608e617 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -425,7 +425,7 @@ function getOptionData({ result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) { result.alternateText = ReportUtils.formatReportLastMessageText(Parser.htmlToText(`${lastActorDisplayName}: ${lastMessageText}`)); - } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG) { + } else if (ReportActionsUtils.isTagModificationAction(lastAction?.actionName)) { result.alternateText = PolicyUtils.getCleanedTagName(ReportActionsUtils.getReportActionMessage(lastAction)?.text ?? ''); } else if (lastAction && ReportActionsUtils.isOldDotReportAction(lastAction)) { result.alternateText = ReportActionsUtils.getMessageOfOldDotReportAction(lastAction); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index bd19dff420380..d1170713a8654 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -652,7 +652,7 @@ function ReportActionItem({ children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { children = ; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG) { + } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { children = ;