From 959c3df10ef1c54e32bca5220019e3fd4fc37eae Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 28 Nov 2024 08:13:45 +0530 Subject: [PATCH 01/38] fix: Chat - Most of the workspace modifying settings messages are not translated in #Admins. Signed-off-by: krishna2323 --- src/languages/en.ts | 6 +++ src/languages/es.ts | 6 +++ src/languages/params.ts | 6 +++ src/libs/ReportUtils.ts | 43 +++++++++++++++++++ src/libs/SidebarUtils.ts | 4 ++ .../report/ContextMenu/ContextMenuActions.tsx | 4 ++ src/pages/home/report/ReportActionItem.tsx | 4 ++ src/types/onyx/OriginalMessage.ts | 12 ++++++ 8 files changed, 85 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1dc859b007bc..d0f9b3187ebc 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -166,6 +166,8 @@ import type { UntilTimeParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, + UpdatedWorkspaceCurrencyParams, + UpdatedWorkspaceFrequencyParams, UpdateRoleParams, UsePlusButtonParams, UserIsAlreadyMemberParams, @@ -1487,6 +1489,7 @@ const translations = { }, frequencyDescription: 'Choose how often you’d like expenses to submit automatically, or make it manual', frequencies: { + instant: 'Instant', weekly: 'Weekly', monthly: 'Monthly', twiceAMonth: 'Twice a month', @@ -4464,6 +4467,9 @@ const translations = { }, workspaceActions: { renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/languages/es.ts b/src/languages/es.ts index ca1bc8f4680d..5f45f19caf5b 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -165,6 +165,8 @@ import type { UntilTimeParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, + UpdatedWorkspaceCurrencyParams, + UpdatedWorkspaceFrequencyParams, UpdateRoleParams, UsePlusButtonParams, UserIsAlreadyMemberParams, @@ -1488,6 +1490,7 @@ const translations = { }, frequencyDescription: 'Elige la frecuencia de presentación automática de gastos, o preséntalos manualmente', frequencies: { + instant: 'Instante', weekly: 'Semanal', monthly: 'Mensual', twiceAMonth: 'Dos veces al mes', @@ -4513,6 +4516,9 @@ const translations = { }, workspaceActions: { renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/languages/params.ts b/src/languages/params.ts index a2d5e1bee124..8a28b6a13d08 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -286,6 +286,10 @@ type ChangeFieldParams = {oldValue?: string; newValue: string; fieldName: string type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; +type UpdatedWorkspaceCurrencyParams = {oldCurrency: string; newCurrency: string}; + +type UpdatedWorkspaceFrequencyParams = {oldFrequency: string; newFrequency: string}; + type ChangeTypeParams = {oldType: string; newType: string}; type DelegateSubmitParams = {delegateUser: string; originalManager: string}; @@ -771,4 +775,6 @@ export type { WorkspaceLockedPlanTypeParams, CompanyNameParams, ChatWithAccountManagerParams, + UpdatedWorkspaceCurrencyParams, + UpdatedWorkspaceFrequencyParams, }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7ad8d3df1077..bf152c029156 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4817,6 +4817,47 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) { return message; } +function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { + const {oldCurrency, newCurrency} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + const message = + oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : ReportActionsUtils.getReportActionText(action); + return message; +} + +type AutoReportingFrequencyKey = ValueOf; +type AutoReportingFrequencyDisplayNames = Record; + +const getAutoReportingFrequencyDisplayNames = (): AutoReportingFrequencyDisplayNames => ({ + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.monthly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: Localize.translateLocal('workflowsPage.frequencies.daily'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: Localize.translateLocal('workflowsPage.frequencies.weekly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.twiceAMonth'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: Localize.translateLocal('workflowsPage.frequencies.byTrip'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: Localize.translateLocal('workflowsPage.frequencies.manually'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: Localize.translateLocal('workflowsPage.frequencies.instant'), +}); + +function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { + const {oldFrequency, newFrequency} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + + if (!oldFrequency || !newFrequency) { + return ReportActionsUtils.getReportActionText(action); + } + + const frequencyDisplayNames = getAutoReportingFrequencyDisplayNames(); + const oldFrequencyTranslation = frequencyDisplayNames[oldFrequency]?.toLowerCase(); + const newFrequencyTranslation = frequencyDisplayNames[newFrequency]?.toLowerCase(); + + if (!oldFrequencyTranslation || !newFrequencyTranslation) { + return ReportActionsUtils.getReportActionText(action); + } + + return Localize.translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { + oldFrequency: oldFrequencyTranslation, + newFrequency: newFrequencyTranslation, + }); +} + /** * @param iouReportID - the report ID of the IOU report the action belongs to * @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) @@ -8553,6 +8594,8 @@ export { getIOUForwardedMessage, getRejectedReportMessage, getWorkspaceNameUpdatedMessage, + getWorkspaceCurrencyUpdateMessage, + getWorkspaceFrequencyUpdateMessage, getReportAutomaticallySubmittedMessage, getIOUSubmittedMessage, getIcons, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index f4979f942363..dd7e593c96af 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -459,6 +459,10 @@ function getOptionData({ result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`; } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { result.alternateText = ReportUtils.getWorkspaceNameUpdatedMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { + result.alternateText = ReportUtils.getWorkspaceCurrencyUpdateMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { + result.alternateText = ReportUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 705b85d4c3fc..38a8264ef702 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -414,6 +414,10 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(logMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { Clipboard.setString(ReportUtils.getWorkspaceNameUpdatedMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { + Clipboard.setString(ReportUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { + Clipboard.setString(ReportUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 399550069c0a..288ddf57311d 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -704,6 +704,10 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index fd94531abb0f..2fcd5a0f08cb 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -276,6 +276,18 @@ type OriginalMessageChangeLog = { /** Old role of user */ oldValue?: string; + /** Old currency of the workspace */ + oldCurrency?: string; + + /** New currency of the workspace */ + newCurrency?: string; + + /** Old frequency of the workspace */ + oldFrequency?: ValueOf; + + /** New frequency of the workspace */ + newFrequency?: ValueOf; + /** Name of connection */ connectionName?: AllConnectionName; }; From b06352bb8a290e73a25e6f64293f7511bf8ae6b9 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 3 Dec 2024 07:29:59 +0530 Subject: [PATCH 02/38] add translations for 'CORPORATE_UPGRADE' & 'ADD_CATEGORY'. Signed-off-by: krishna2323 --- src/languages/en.ts | 8 +++++--- src/languages/es.ts | 8 +++++--- src/libs/ReportUtils.ts | 13 +++++++++++++ src/libs/SidebarUtils.ts | 4 ++++ .../home/report/ContextMenu/ContextMenuActions.tsx | 4 ++++ src/pages/home/report/ReportActionItem.tsx | 4 ++++ src/types/onyx/OriginalMessage.ts | 3 +++ 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1e83d951665d..33cb72ace5ef 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4444,10 +4444,8 @@ const translations = { }, }, workspaceActions: { + addCategory: ({categoryName}: {categoryName: string}) => `added the category "${categoryName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => - `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { @@ -4462,6 +4460,10 @@ const translations = { other: `removed you from ${joinedNames}'s approval workflows and workspace chats. Previously submitted reports will remain available for approval in your Inbox.`, }; }, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, + updatedWorkspaceCorporatePlan: 'upgraded this workspace to the Control plan', }, roomMembersPage: { memberNotFound: 'Member not found.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 0931fb0911a6..1f55efe3a2e6 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4493,10 +4493,8 @@ const translations = { }, }, workspaceActions: { + addCategory: ({categoryName}: {categoryName: string}) => `agregó la categoría "${categoryName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => - `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { @@ -4511,6 +4509,10 @@ const translations = { other: `te eliminó de los flujos de trabajo de aprobaciones y de los chats del espacio de trabajo de ${joinedNames}. Los informes enviados anteriormente seguirán estando disponibles para su aprobación en tu bandeja de entrada.`, }; }, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, + updatedWorkspaceCorporatePlan: 'mejoró este espacio de trabajo al plan Controlar', }, roomMembersPage: { memberNotFound: 'Miembro no encontrado.', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7402804a4990..067fb7e8aeca 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4868,6 +4868,18 @@ function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { }); } +function getWorkspaceAddCategoryMessage(action: ReportAction): string { + const {categoryName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + + if (!categoryName) { + return ReportActionsUtils.getReportActionText(action); + } + + return Localize.translateLocal('workspaceActions.addCategory', { + categoryName, + }); +} + /** * @param iouReportID - the report ID of the IOU report the action belongs to * @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) @@ -8822,6 +8834,7 @@ export { getAllReportErrors, getAllReportActionsErrorsAndReportActionThatRequiresAttention, hasInvoiceReports, + getWorkspaceAddCategoryMessage, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index dd7e593c96af..bce7cfacf524 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -463,6 +463,10 @@ function getOptionData({ result.alternateText = ReportUtils.getWorkspaceCurrencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { result.alternateText = ReportUtils.getWorkspaceFrequencyUpdateMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { + result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY)) { + result.alternateText = ReportUtils.getWorkspaceAddCategoryMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 38a8264ef702..523ec8362b52 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -418,6 +418,10 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(ReportUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { Clipboard.setString(ReportUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { + Clipboard.setString(ReportUtils.getWorkspaceAddCategoryMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 8c105d26bb9e..fd42a4910b9a 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -708,6 +708,10 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 2fcd5a0f08cb..8788153d9dde 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -290,6 +290,9 @@ type OriginalMessageChangeLog = { /** Name of connection */ connectionName?: AllConnectionName; + + /** Name of the added category */ + categoryName?: string; }; /** Model of `join policy changelog` report action */ From 0c5061a6307ae0f75d4cb1355585d3a00dc757e7 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 3 Dec 2024 08:00:17 +0530 Subject: [PATCH 03/38] refactor and added more translations. Signed-off-by: krishna2323 --- src/languages/en.ts | 5 +- src/languages/es.ts | 5 +- src/languages/params.ts | 3 + src/libs/ReportUtils.ts | 29 ++++++++-- src/libs/SidebarUtils.ts | 7 ++- .../report/ContextMenu/ContextMenuActions.tsx | 8 ++- src/pages/home/report/ReportActionItem.tsx | 8 ++- src/types/onyx/OriginalMessage.ts | 56 ++++++++++++++++++- 8 files changed, 106 insertions(+), 15 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 33cb72ace5ef..60c50b44b1ef 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -168,6 +168,7 @@ import type { UntilTimeParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, + UpdatedWorkspaceCategoryParams, UpdatedWorkspaceCurrencyParams, UpdatedWorkspaceFrequencyParams, UpdateRoleParams, @@ -4444,7 +4445,9 @@ const translations = { }, }, workspaceActions: { - addCategory: ({categoryName}: {categoryName: string}) => `added the category "${categoryName}"`, + addCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `added the category "${categoryName}"`, + deleteCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `removed the category "${categoryName}"`, + updateCategory: ({oldValue, categoryName}: UpdatedWorkspaceCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/es.ts b/src/languages/es.ts index 1f55efe3a2e6..4a388764d522 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -167,6 +167,7 @@ import type { UntilTimeParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, + UpdatedWorkspaceCategoryParams, UpdatedWorkspaceCurrencyParams, UpdatedWorkspaceFrequencyParams, UpdateRoleParams, @@ -4493,7 +4494,9 @@ const translations = { }, }, workspaceActions: { - addCategory: ({categoryName}: {categoryName: string}) => `agregó la categoría "${categoryName}"`, + addCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `agregó la categoría "${categoryName}"`, + deleteCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `eliminó la categoría "${categoryName}"`, + updateCategory: ({oldValue, categoryName}: UpdatedWorkspaceCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index 608eb1d10e52..47e1c51417df 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -288,6 +288,8 @@ type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; type UpdatedWorkspaceCurrencyParams = {oldCurrency: string; newCurrency: string}; +type UpdatedWorkspaceCategoryParams = {categoryName: string; oldValue?: boolean}; + type UpdatedWorkspaceFrequencyParams = {oldFrequency: string; newFrequency: string}; type ChangeTypeParams = {oldType: string; newType: string}; @@ -782,4 +784,5 @@ export type { ChatWithAccountManagerParams, UpdatedWorkspaceCurrencyParams, UpdatedWorkspaceFrequencyParams, + UpdatedWorkspaceCategoryParams, }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 067fb7e8aeca..fa0143f7ef0d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4868,16 +4868,33 @@ function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { }); } -function getWorkspaceAddCategoryMessage(action: ReportAction): string { - const {categoryName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; +function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { + const {categoryName, oldValue} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; if (!categoryName) { return ReportActionsUtils.getReportActionText(action); } - return Localize.translateLocal('workspaceActions.addCategory', { - categoryName, - }); + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { + return Localize.translateLocal('workspaceActions.addCategory', { + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) { + return Localize.translateLocal('workspaceActions.deleteCategory', { + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) { + return Localize.translateLocal('workspaceActions.updateCategory', { + oldValue: !!oldValue, + categoryName, + }); + } + + return ReportActionsUtils.getReportActionText(action); } /** @@ -8834,7 +8851,7 @@ export { getAllReportErrors, getAllReportActionsErrorsAndReportActionThatRequiresAttention, hasInvoiceReports, - getWorkspaceAddCategoryMessage, + getWorkspaceCategoryUpdateMessage, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index bce7cfacf524..e2910ae2f907 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -465,8 +465,11 @@ function getOptionData({ result.alternateText = ReportUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY)) { - result.alternateText = ReportUtils.getWorkspaceAddCategoryMessage(lastAction); + } else if ( + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) + ) { + result.alternateText = ReportUtils.getWorkspaceCategoryUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 523ec8362b52..5a69c434318b 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -420,8 +420,12 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(ReportUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { - Clipboard.setString(ReportUtils.getWorkspaceAddCategoryMessage(reportAction)); + } else if ( + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY + ) { + Clipboard.setString(ReportUtils.getWorkspaceCategoryUpdateMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index fd42a4910b9a..65d33203fff5 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -710,8 +710,12 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { children = ; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { - children = ; + } else if ( + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY + ) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 8788153d9dde..96f3ec5a6fec 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -295,6 +295,60 @@ type OriginalMessageChangeLog = { categoryName?: string; }; +/** Model of change log */ +type OriginalMessagePolicyChangeLog = { + /** Account IDs of users that either got invited or removed from the room */ + targetAccountIDs?: number[]; + + /** Name of the chat room */ + roomName?: string; + + /** Description of the chat room */ + description?: string; + + /** ID of the report */ + reportID?: number; + + /** Old name of the workspace */ + oldName?: string; + + /** New name of the workspace */ + newName?: string; + + /** Email of user */ + email?: string; + + /** Role of user */ + role?: string; + + /** When was it last modified */ + lastModified?: string; + + /** New Value */ + newValue?: boolean; + + /** Old Value */ + oldValue?: boolean; + + /** Old currency of the workspace */ + oldCurrency?: string; + + /** New currency of the workspace */ + newCurrency?: string; + + /** Old frequency of the workspace */ + oldFrequency?: ValueOf; + + /** New frequency of the workspace */ + newFrequency?: ValueOf; + + /** Name of connection */ + connectionName?: AllConnectionName; + + /** Name of the added category */ + categoryName?: string; +}; + /** Model of `join policy changelog` report action */ type OriginalMessageJoinPolicyChangeLog = { /** What was the invited user decision */ @@ -652,7 +706,7 @@ type OriginalMessageMap = { [CONST.REPORT.ACTIONS.TYPE.CARD_ASSIGNED]: OriginalMessageCard; [CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED]: OriginalMessageIntegrationSyncFailed; } & OldDotOriginalMessageMap & { - [T in ValueOf]: OriginalMessageChangeLog; + [T in ValueOf]: OriginalMessagePolicyChangeLog; } & { [T in ValueOf]: OriginalMessageChangeLog; }; From a2487bf5bae22195da05f25bb6016d9032e280a0 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 3 Dec 2024 08:02:21 +0530 Subject: [PATCH 04/38] minor fix. Signed-off-by: krishna2323 --- src/libs/SidebarUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index e2910ae2f907..d42e61638968 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -467,7 +467,8 @@ function getOptionData({ result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); } else if ( ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || - ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) ) { result.alternateText = ReportUtils.getWorkspaceCategoryUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { From bde1c30f7297cca5199389b486c7246cdb53bf19 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 9 Dec 2024 03:57:12 +0530 Subject: [PATCH 05/38] add translations form 'POLICYCHANGELOG_UPDATE_FIELD' & 'POLICYCHANGELOG_SET_CATEGORY_NAME'. Signed-off-by: krishna2323 --- src/CONST.ts | 8 +++++ src/languages/en.ts | 20 ++++++----- src/languages/es.ts | 19 ++++++----- src/languages/params.ts | 15 ++++---- src/libs/ReportActionsUtils.ts | 4 +-- src/libs/ReportUtils.ts | 34 ++++++++++++++----- src/libs/SidebarUtils.ts | 5 ++- .../report/ContextMenu/ContextMenuActions.tsx | 5 ++- src/pages/home/report/ReportActionItem.tsx | 5 ++- src/types/onyx/OriginalMessage.ts | 7 ++-- 10 files changed, 84 insertions(+), 38 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 44b2fd16f64c..cb78ebc3d5d1 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2490,6 +2490,14 @@ const CONST = { SMARTREPORT: 'SMARTREPORT', BILLCOM: 'BILLCOM', }, + APPROVAL_MODE_VALUES: { + OPTIONAL: 'Submit and Close', + BASIC: 'Submit and Approve', + ADVANCED: 'ADVANCED', + DYNAMICEXTERNAL: 'DYNAMIC_EXTERNAL', + SMARTREPORT: 'SMARTREPORT', + BILLCOM: 'BILLCOM', + }, ROOM_PREFIX: '#', CUSTOM_UNIT_RATE_BASE_OFFSET: 100, OWNER_EMAIL_FAKE: '_FAKE_', diff --git a/src/languages/en.ts b/src/languages/en.ts index 688929406363..2353f613fa3d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -166,11 +166,12 @@ import type { UnapproveWithIntegrationWarningParams, UnshareParams, UntilTimeParams, + UpdatedPolicyCategoryNameParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyFrequencyParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, - UpdatedWorkspaceCategoryParams, - UpdatedWorkspaceCurrencyParams, - UpdatedWorkspaceFrequencyParams, UpdateRoleParams, UsePlusButtonParams, UserIsAlreadyMemberParams, @@ -4451,9 +4452,10 @@ const translations = { }, }, workspaceActions: { - addCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `added the category "${categoryName}"`, - deleteCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `removed the category "${categoryName}"`, - updateCategory: ({oldValue, categoryName}: UpdatedWorkspaceCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, + addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `added the category "${categoryName}"`, + deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, + updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, + setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; @@ -4469,10 +4471,10 @@ const translations = { other: `removed you from ${joinedNames}'s approval workflows and workspace chats. Previously submitted reports will remain available for approval in your Inbox.`, }; }, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => - `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, updatedWorkspaceCorporatePlan: 'upgraded this workspace to the Control plan', + updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `updated the Approval Mode from "${oldValue}" to "${newValue}".`, }, roomMembersPage: { memberNotFound: 'Member not found.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 9f85a0e5f076..69a8e435d41a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -165,11 +165,12 @@ import type { UnapproveWithIntegrationWarningParams, UnshareParams, UntilTimeParams, + UpdatedPolicyCategoryNameParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyFrequencyParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, - UpdatedWorkspaceCategoryParams, - UpdatedWorkspaceCurrencyParams, - UpdatedWorkspaceFrequencyParams, UpdateRoleParams, UsePlusButtonParams, UserIsAlreadyMemberParams, @@ -4500,9 +4501,10 @@ const translations = { }, }, workspaceActions: { - addCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `agregó la categoría "${categoryName}"`, - deleteCategory: ({categoryName}: UpdatedWorkspaceCategoryParams) => `eliminó la categoría "${categoryName}"`, - updateCategory: ({oldValue, categoryName}: UpdatedWorkspaceCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, + addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `agregó la categoría "${categoryName}"`, + deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, + updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, + setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; @@ -4518,10 +4520,11 @@ const translations = { other: `te eliminó de los flujos de trabajo de aprobaciones y de los chats del espacio de trabajo de ${joinedNames}. Los informes enviados anteriormente seguirán estando disponibles para su aprobación en tu bandeja de entrada.`, }; }, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedWorkspaceCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedWorkspaceFrequencyParams) => + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, updatedWorkspaceCorporatePlan: 'mejoró este espacio de trabajo al plan Controlar', + updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `Actualizó el Modo de Aprobación de "${oldValue}" a "${newValue}".`, }, roomMembersPage: { memberNotFound: 'Miembro no encontrado.', diff --git a/src/languages/params.ts b/src/languages/params.ts index 47e1c51417df..c1b3bcc7b461 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -286,11 +286,13 @@ type ChangeFieldParams = {oldValue?: string; newValue: string; fieldName: string type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; -type UpdatedWorkspaceCurrencyParams = {oldCurrency: string; newCurrency: string}; +type UpdatedPolicyCurrencyParams = {oldCurrency: string; newCurrency: string}; -type UpdatedWorkspaceCategoryParams = {categoryName: string; oldValue?: boolean}; +type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; -type UpdatedWorkspaceFrequencyParams = {oldFrequency: string; newFrequency: string}; +type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; + +type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; type ChangeTypeParams = {oldType: string; newType: string}; @@ -782,7 +784,8 @@ export type { CompanyNameParams, CustomUnitRateParams, ChatWithAccountManagerParams, - UpdatedWorkspaceCurrencyParams, - UpdatedWorkspaceFrequencyParams, - UpdatedWorkspaceCategoryParams, + UpdatedPolicyCurrencyParams, + UpdatedPolicyFrequencyParams, + UpdatedPolicyCategoryParams, + UpdatedPolicyCategoryNameParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 8d828f457ece..ef1b5475bf49 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1710,8 +1710,8 @@ function getPolicyChangeLogChangeRoleMessage(reportAction: OnyxInputOrEntry) ?? {}; + const {categoryName, oldValue, newName, oldName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - if (!categoryName) { - return ReportActionsUtils.getReportActionText(action); - } - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY && categoryName) { return Localize.translateLocal('workspaceActions.addCategory', { categoryName, }); } - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY && categoryName) { return Localize.translateLocal('workspaceActions.deleteCategory', { categoryName, }); } - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) { + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY && categoryName) { return Localize.translateLocal('workspaceActions.updateCategory', { oldValue: !!oldValue, categoryName, }); } + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME && oldName && newName) { + return Localize.translateLocal('workspaceActions.setCategoryName', { + oldName, + newName, + }); + } + + return ReportActionsUtils.getReportActionText(action); +} + +function getWorkspaceUpdateFieldMessage(action: ReportAction): string { + const {newValue, oldValue, updatedField} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; + + if (updatedField && updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && typeof newValue === 'string' && typeof oldValue === 'string') { + return Localize.translateLocal('workspaceActions.updateApprovalMode', { + oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ?? oldValue, + newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ?? newValue, + fieldName: updatedField, + }); + } + return ReportActionsUtils.getReportActionText(action); } @@ -8876,6 +8893,7 @@ export { hasInvoiceReports, getWorkspaceCategoryUpdateMessage, getReportMetadata, + getWorkspaceUpdateFieldMessage, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index d8c1a9234a27..aa1caf942fd4 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -471,7 +471,8 @@ function getOptionData({ } else if ( ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || - ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) || + ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { result.alternateText = ReportUtils.getWorkspaceCategoryUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { @@ -490,6 +491,8 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { + result.alternateText = ReportUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 5a69c434318b..5d42e8f2525d 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -423,7 +423,8 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if ( reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || - reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || + reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { Clipboard.setString(ReportUtils.getWorkspaceCategoryUpdateMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { @@ -486,6 +487,8 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { + setClipboardMessage(ReportUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''}; setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage})); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 65d33203fff5..838b6442ea37 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -713,7 +713,8 @@ function ReportActionItem({ } else if ( action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || - action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { @@ -722,6 +723,8 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { + children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; } else if ( diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 96f3ec5a6fec..a4c550b33d20 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -325,10 +325,10 @@ type OriginalMessagePolicyChangeLog = { lastModified?: string; /** New Value */ - newValue?: boolean; + newValue?: boolean | string; /** Old Value */ - oldValue?: boolean; + oldValue?: boolean | string; /** Old currency of the workspace */ oldCurrency?: string; @@ -347,6 +347,9 @@ type OriginalMessagePolicyChangeLog = { /** Name of the added category */ categoryName?: string; + + /** Name of the updated field */ + updatedField?: string; }; /** Model of `join policy changelog` report action */ From 2e7cd0f0e9f25f41c58c27f4ccfe3555c20ff8f4 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 9 Dec 2024 03:58:25 +0530 Subject: [PATCH 06/38] minor update. Signed-off-by: krishna2323 --- src/types/onyx/OriginalMessage.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index a4c550b33d20..a27c5737110c 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -276,18 +276,6 @@ type OriginalMessageChangeLog = { /** Old role of user */ oldValue?: string; - /** Old currency of the workspace */ - oldCurrency?: string; - - /** New currency of the workspace */ - newCurrency?: string; - - /** Old frequency of the workspace */ - oldFrequency?: ValueOf; - - /** New frequency of the workspace */ - newFrequency?: ValueOf; - /** Name of connection */ connectionName?: AllConnectionName; From 5eb19d9f5b0a2dbd22c6dc6abb0a2a965f80f81d Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 9 Dec 2024 04:17:27 +0530 Subject: [PATCH 07/38] minor update. Signed-off-by: krishna2323 --- src/libs/ReportUtils.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e42aaa281d33..1e7409497554 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4903,10 +4903,15 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { function getWorkspaceUpdateFieldMessage(action: ReportAction): string { const {newValue, oldValue, updatedField} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - if (updatedField && updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && typeof newValue === 'string' && typeof oldValue === 'string') { + if ( + updatedField && + updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && + CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] && + CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] + ) { return Localize.translateLocal('workspaceActions.updateApprovalMode', { - oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ?? oldValue, - newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ?? newValue, + oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], + newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], fieldName: updatedField, }); } From 2e277b751b80afd6bbd1780bd82f41b5ffc6c2e6 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 9 Dec 2024 04:35:39 +0530 Subject: [PATCH 08/38] move action messages util function to ReportActionsUtils.ts. Signed-off-by: krishna2323 --- src/libs/ReportActionsUtils.ts | 102 +++++++++++++++++ src/libs/ReportUtils.ts | 103 ------------------ src/libs/SidebarUtils.ts | 10 +- .../report/ContextMenu/ContextMenuActions.tsx | 10 +- src/pages/home/report/ReportActionItem.tsx | 12 +- 5 files changed, 119 insertions(+), 118 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index ef1b5475bf49..9251301d69d2 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1721,6 +1721,103 @@ function isPolicyChangeLogDeleteMemberMessage( return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE); } +function getWorkspaceNameUpdatedMessage(action: ReportAction) { + const {oldName, newName} = getOriginalMessage(action as ReportAction) ?? {}; + const message = oldName && newName ? Localize.translateLocal('workspaceActions.renamedWorkspaceNameAction', {oldName, newName}) : getReportActionText(action); + return message; +} + +function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { + const {oldCurrency, newCurrency} = getOriginalMessage(action as ReportAction) ?? {}; + const message = oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : getReportActionText(action); + return message; +} + +type AutoReportingFrequencyKey = ValueOf; +type AutoReportingFrequencyDisplayNames = Record; + +const getAutoReportingFrequencyDisplayNames = (): AutoReportingFrequencyDisplayNames => ({ + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.monthly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: Localize.translateLocal('workflowsPage.frequencies.daily'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: Localize.translateLocal('workflowsPage.frequencies.weekly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.twiceAMonth'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: Localize.translateLocal('workflowsPage.frequencies.byTrip'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: Localize.translateLocal('workflowsPage.frequencies.manually'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: Localize.translateLocal('workflowsPage.frequencies.instant'), +}); + +function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { + const {oldFrequency, newFrequency} = getOriginalMessage(action as ReportAction) ?? {}; + + if (!oldFrequency || !newFrequency) { + return getReportActionText(action); + } + + const frequencyDisplayNames = getAutoReportingFrequencyDisplayNames(); + const oldFrequencyTranslation = frequencyDisplayNames[oldFrequency]?.toLowerCase(); + const newFrequencyTranslation = frequencyDisplayNames[newFrequency]?.toLowerCase(); + + if (!oldFrequencyTranslation || !newFrequencyTranslation) { + return getReportActionText(action); + } + + return Localize.translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { + oldFrequency: oldFrequencyTranslation, + newFrequency: newFrequencyTranslation, + }); +} + +function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { + const {categoryName, oldValue, newName, oldName} = getOriginalMessage(action as ReportAction) ?? {}; + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY && categoryName) { + return Localize.translateLocal('workspaceActions.addCategory', { + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY && categoryName) { + return Localize.translateLocal('workspaceActions.deleteCategory', { + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY && categoryName) { + return Localize.translateLocal('workspaceActions.updateCategory', { + oldValue: !!oldValue, + categoryName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME && oldName && newName) { + return Localize.translateLocal('workspaceActions.setCategoryName', { + oldName, + newName, + }); + } + + return getReportActionText(action); +} + +function getWorkspaceUpdateFieldMessage(action: ReportAction): string { + const {newValue, oldValue, updatedField} = getOriginalMessage(action as ReportAction) ?? {}; + + if ( + updatedField && + updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && + CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] && + CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] + ) { + return Localize.translateLocal('workspaceActions.updateApprovalMode', { + oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], + newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], + fieldName: updatedField, + }); + } + + return getReportActionText(action); +} + function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogDeleteMemberMessage(reportAction)) { return ''; @@ -1960,6 +2057,11 @@ export { getActionableJoinRequestPendingReportAction, getReportActionsLength, wasActionCreatedWhileOffline, + getWorkspaceCategoryUpdateMessage, + getWorkspaceUpdateFieldMessage, + getWorkspaceNameUpdatedMessage, + getWorkspaceCurrencyUpdateMessage, + getWorkspaceFrequencyUpdateMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 1e7409497554..72dff3aa0eff 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4821,104 +4821,6 @@ function getRejectedReportMessage() { return Localize.translateLocal('iou.rejectedThisReport'); } -function getWorkspaceNameUpdatedMessage(action: ReportAction) { - const {oldName, newName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - const message = oldName && newName ? Localize.translateLocal('workspaceActions.renamedWorkspaceNameAction', {oldName, newName}) : ReportActionsUtils.getReportActionText(action); - return message; -} - -function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { - const {oldCurrency, newCurrency} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - const message = - oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : ReportActionsUtils.getReportActionText(action); - return message; -} - -type AutoReportingFrequencyKey = ValueOf; -type AutoReportingFrequencyDisplayNames = Record; - -const getAutoReportingFrequencyDisplayNames = (): AutoReportingFrequencyDisplayNames => ({ - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.monthly'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: Localize.translateLocal('workflowsPage.frequencies.daily'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: Localize.translateLocal('workflowsPage.frequencies.weekly'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.twiceAMonth'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: Localize.translateLocal('workflowsPage.frequencies.byTrip'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: Localize.translateLocal('workflowsPage.frequencies.manually'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: Localize.translateLocal('workflowsPage.frequencies.instant'), -}); - -function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { - const {oldFrequency, newFrequency} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - - if (!oldFrequency || !newFrequency) { - return ReportActionsUtils.getReportActionText(action); - } - - const frequencyDisplayNames = getAutoReportingFrequencyDisplayNames(); - const oldFrequencyTranslation = frequencyDisplayNames[oldFrequency]?.toLowerCase(); - const newFrequencyTranslation = frequencyDisplayNames[newFrequency]?.toLowerCase(); - - if (!oldFrequencyTranslation || !newFrequencyTranslation) { - return ReportActionsUtils.getReportActionText(action); - } - - return Localize.translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { - oldFrequency: oldFrequencyTranslation, - newFrequency: newFrequencyTranslation, - }); -} - -function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { - const {categoryName, oldValue, newName, oldName} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.addCategory', { - categoryName, - }); - } - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.deleteCategory', { - categoryName, - }); - } - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.updateCategory', { - oldValue: !!oldValue, - categoryName, - }); - } - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME && oldName && newName) { - return Localize.translateLocal('workspaceActions.setCategoryName', { - oldName, - newName, - }); - } - - return ReportActionsUtils.getReportActionText(action); -} - -function getWorkspaceUpdateFieldMessage(action: ReportAction): string { - const {newValue, oldValue, updatedField} = ReportActionsUtils.getOriginalMessage(action as ReportAction) ?? {}; - - if ( - updatedField && - updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && - CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] && - CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] - ) { - return Localize.translateLocal('workspaceActions.updateApprovalMode', { - oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], - newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], - fieldName: updatedField, - }); - } - - return ReportActionsUtils.getReportActionText(action); -} - /** * @param iouReportID - the report ID of the IOU report the action belongs to * @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) @@ -8671,9 +8573,6 @@ export { getReportAutomaticallyForwardedMessage, getIOUForwardedMessage, getRejectedReportMessage, - getWorkspaceNameUpdatedMessage, - getWorkspaceCurrencyUpdateMessage, - getWorkspaceFrequencyUpdateMessage, getReportAutomaticallySubmittedMessage, getIOUSubmittedMessage, getIcons, @@ -8896,9 +8795,7 @@ export { getAllReportErrors, getAllReportActionsErrorsAndReportActionThatRequiresAttention, hasInvoiceReports, - getWorkspaceCategoryUpdateMessage, getReportMetadata, - getWorkspaceUpdateFieldMessage, }; export type { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index aa1caf942fd4..0ef1b14da066 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -461,11 +461,11 @@ function getOptionData({ } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) { result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`; } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { - result.alternateText = ReportUtils.getWorkspaceNameUpdatedMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceNameUpdatedMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { - result.alternateText = ReportUtils.getWorkspaceCurrencyUpdateMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { - result.alternateText = ReportUtils.getWorkspaceFrequencyUpdateMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); } else if ( @@ -474,7 +474,7 @@ function getOptionData({ ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) || ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { - result.alternateText = ReportUtils.getWorkspaceCategoryUpdateMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { @@ -492,7 +492,7 @@ function getOptionData({ } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - result.alternateText = ReportUtils.getWorkspaceUpdateFieldMessage(lastAction); + result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 5d42e8f2525d..e59bd6a17f48 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -413,11 +413,11 @@ const ContextMenuActions: ContextMenuAction[] = [ const logMessage = ReportActionsUtils.getMemberChangeMessageFragment(reportAction).html ?? ''; setClipboardMessage(logMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { - Clipboard.setString(ReportUtils.getWorkspaceNameUpdatedMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getWorkspaceNameUpdatedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - Clipboard.setString(ReportUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - Clipboard.setString(ReportUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); } else if ( @@ -426,7 +426,7 @@ const ContextMenuActions: ContextMenuAction[] = [ reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { - Clipboard.setString(ReportUtils.getWorkspaceCategoryUpdateMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { @@ -488,7 +488,7 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - setClipboardMessage(ReportUtils.getWorkspaceUpdateFieldMessage(reportAction)); + setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''}; setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage})); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 838b6442ea37..8f96cd3227bc 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -703,11 +703,11 @@ function ReportActionItem({ } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { children = ; } else if ( @@ -716,7 +716,7 @@ function ReportActionItem({ action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { @@ -724,9 +724,11 @@ function ReportActionItem({ } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { - children = ; + children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { + children = ; } else if ( ReportActionsUtils.isActionOfType( action, From 1e8fc36b5b860e736b756fdfcef2b8c506e5dc5e Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sat, 14 Dec 2024 16:00:32 +0530 Subject: [PATCH 09/38] fix merge conflicts. Signed-off-by: krishna2323 --- src/languages/en.ts | 1 - src/languages/es.ts | 1 - src/pages/home/report/ReportActionItem.tsx | 1118 +------------------- 3 files changed, 50 insertions(+), 1070 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 2353f613fa3d..d4a6c0027c65 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4456,7 +4456,6 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, - renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace from ${oldName} to ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/languages/es.ts b/src/languages/es.ts index 69a8e435d41a..0fff9ee2acb8 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4505,7 +4505,6 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, - renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo de ${oldName} a ${newName}`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 8f96cd3227bc..1887bf9d348a 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -1,170 +1,20 @@ -import lodashIsEqual from 'lodash/isEqual'; -import React, {memo, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; -import type {GestureResponderEvent, TextInput} from 'react-native'; -import {InteractionManager, View} from 'react-native'; -import type {OnyxEntry} from 'react-native-onyx'; +import React, {useMemo} from 'react'; import {useOnyx} from 'react-native-onyx'; -import type {Emoji} from '@assets/emojis/types'; -import {AttachmentContext} from '@components/AttachmentContext'; -import Button from '@components/Button'; -import DisplayNames from '@components/DisplayNames'; -import Hoverable from '@components/Hoverable'; -import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext'; -import Icon from '@components/Icon'; -import * as Expensicons from '@components/Icon/Expensicons'; -import InlineSystemMessage from '@components/InlineSystemMessage'; -import KYCWall from '@components/KYCWall'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import type {OnyxEntry} from 'react-native-onyx'; import {useBlockedFromConcierge, usePersonalDetails} from '@components/OnyxProvider'; -import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction'; -import ReportActionItemEmojiReactions from '@components/Reactions/ReportActionItemEmojiReactions'; -import RenderHTML from '@components/RenderHTML'; -import type {ActionableItem} from '@components/ReportActionItem/ActionableItemButtons'; -import ActionableItemButtons from '@components/ReportActionItem/ActionableItemButtons'; -import ChronosOOOListActions from '@components/ReportActionItem/ChronosOOOListActions'; -import ExportIntegration from '@components/ReportActionItem/ExportIntegration'; -import IssueCardMessage from '@components/ReportActionItem/IssueCardMessage'; -import MoneyRequestAction from '@components/ReportActionItem/MoneyRequestAction'; -import ReportPreview from '@components/ReportActionItem/ReportPreview'; -import TaskAction from '@components/ReportActionItem/TaskAction'; -import TaskPreview from '@components/ReportActionItem/TaskPreview'; -import TripRoomPreview from '@components/ReportActionItem/TripRoomPreview'; -import {ShowContextMenuContext} from '@components/ShowContextMenuContext'; -import Text from '@components/Text'; -import UnreadActionIndicator from '@components/UnreadActionIndicator'; -import useLocalize from '@hooks/useLocalize'; -import usePrevious from '@hooks/usePrevious'; -import useReportScrollManager from '@hooks/useReportScrollManager'; -import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useStyleUtils from '@hooks/useStyleUtils'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import ControlSelection from '@libs/ControlSelection'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as ErrorUtils from '@libs/ErrorUtils'; -import focusComposerWithDelay from '@libs/focusComposerWithDelay'; import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; -import Navigation from '@libs/Navigation/Navigation'; -import Permissions from '@libs/Permissions'; -import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; -import SelectionScraper from '@libs/SelectionScraper'; -import shouldRenderAddPaymentCard from '@libs/shouldRenderAppPaymentCard'; -import {ReactionListContext} from '@pages/home/ReportScreenContext'; -import * as BankAccounts from '@userActions/BankAccounts'; -import * as EmojiPickerAction from '@userActions/EmojiPickerAction'; -import * as Member from '@userActions/Policy/Member'; import * as Report from '@userActions/Report'; import * as ReportActions from '@userActions/ReportActions'; -import * as Session from '@userActions/Session'; import * as Transaction from '@userActions/Transaction'; -import * as User from '@userActions/User'; -import CONST from '@src/CONST'; +import type CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import type * as OnyxTypes from '@src/types/onyx'; -import type {JoinWorkspaceResolution} from '@src/types/onyx/OriginalMessage'; -import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import {RestrictedReadOnlyContextMenuActions} from './ContextMenu/ContextMenuActions'; -import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu'; -import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu'; -import {hideContextMenu} from './ContextMenu/ReportActionContextMenu'; -import LinkPreviewer from './LinkPreviewer'; -import ReportActionItemBasicMessage from './ReportActionItemBasicMessage'; -import ReportActionItemContentCreated from './ReportActionItemContentCreated'; -import ReportActionItemDraft from './ReportActionItemDraft'; -import ReportActionItemGrouped from './ReportActionItemGrouped'; -import ReportActionItemMessage from './ReportActionItemMessage'; -import ReportActionItemMessageEdit from './ReportActionItemMessageEdit'; -import ReportActionItemSingle from './ReportActionItemSingle'; -import ReportActionItemThread from './ReportActionItemThread'; -import ReportAttachmentsContext from './ReportAttachmentsContext'; - -type ReportActionItemProps = { - /** Report for this action */ - report: OnyxEntry; - - /** The transaction thread report associated with the report for this action, if any */ - transactionThreadReport?: OnyxEntry; - - /** Array of report actions for the report for this action */ - // eslint-disable-next-line react/no-unused-prop-types - reportActions: OnyxTypes.ReportAction[]; - - /** Report action belonging to the report's parent */ - parentReportAction: OnyxEntry; - - /** The transaction thread report's parentReportAction */ - /** It's used by withOnyx HOC */ - // eslint-disable-next-line react/no-unused-prop-types - parentReportActionForTransactionThread?: OnyxEntry; - - /** All the data of the action item */ - action: OnyxTypes.ReportAction; - - /** Should the comment have the appearance of being grouped with the previous comment? */ - displayAsGroup: boolean; - - /** Is this the most recent IOU Action? */ - isMostRecentIOUReportAction: boolean; - - /** Should we display the new marker on top of the comment? */ - shouldDisplayNewMarker: boolean; +import type {ReportAction} from '@src/types/onyx'; +import type {PureReportActionItemProps} from './PureReportActionItem'; +import PureReportActionItem from './PureReportActionItem'; - /** Determines if the avatar is displayed as a subscript (positioned lower than normal) */ - shouldShowSubscriptAvatar?: boolean; - - /** Position index of the report action in the overall report FlatList view */ - index: number; - - /** Flag to show, hide the thread divider line */ - shouldHideThreadDividerLine?: boolean; - - linkedReportActionID?: string; - - /** Callback to be called on onPress */ - onPress?: () => void; - - /** If this is the first visible report action */ - isFirstVisibleReportAction: boolean; - - /** - * Is the action a thread's parent reportAction viewed from within the thread report? - * It will be false if we're viewing the same parent report action from the report it belongs to rather than the thread. - */ - isThreadReportParentAction?: boolean; - - /** IF the thread divider line will be used */ - shouldUseThreadDividerLine?: boolean; - - /** Whether context menu should be displayed */ - shouldDisplayContextMenu?: boolean; -}; - -function ReportActionItem({ - action, - report, - transactionThreadReport, - linkedReportActionID, - displayAsGroup, - index, - isMostRecentIOUReportAction, - parentReportAction, - shouldDisplayNewMarker, - shouldHideThreadDividerLine = false, - shouldShowSubscriptAvatar = false, - onPress = undefined, - isFirstVisibleReportAction = false, - isThreadReportParentAction = false, - shouldUseThreadDividerLine = false, - shouldDisplayContextMenu = true, - parentReportActionForTransactionThread, -}: ReportActionItemProps) { - const {translate} = useLocalize(); - const {shouldUseNarrowLayout} = useResponsiveLayout(); - const blockedFromConcierge = useBlockedFromConcierge(); +function ReportActionItem({action, report, ...props}: PureReportActionItemProps) { const reportID = report?.reportID ?? ''; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const originalReportID = useMemo(() => ReportUtils.getOriginalReportID(reportID, action) || '-1', [reportID, action]); @@ -181,926 +31,58 @@ function ReportActionItem({ `${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID ?? -1 : -1}`, {selector: (transaction) => transaction?.errorFields?.route ?? null}, ); - const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID); - const theme = useTheme(); - const styles = useThemeStyles(); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- This is needed to prevent the app from crashing when the app is using imported state. const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || '-1'}`); - const StyleUtils = useStyleUtils(); - const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT; - const [isContextMenuActive, setIsContextMenuActive] = useState(() => ReportActionContextMenu.isActiveReportAction(action.reportActionID)); - const [isEmojiPickerActive, setIsEmojiPickerActive] = useState(); - const [isPaymentMethodPopoverActive, setIsPaymentMethodPopoverActive] = useState(); - const [isHidden, setIsHidden] = useState(false); - const [moderationDecision, setModerationDecision] = useState(CONST.MODERATION.MODERATOR_DECISION_APPROVED); - const reactionListRef = useContext(ReactionListContext); - const {updateHiddenAttachments} = useContext(ReportAttachmentsContext); - const textInputRef = useRef(null); - const popoverAnchorRef = useRef>(null); - const downloadedPreviews = useRef([]); - const prevDraftMessage = usePrevious(draftMessage); const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated}); // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || -1}`); - const isReportActionLinked = linkedReportActionID && action.reportActionID && linkedReportActionID === action.reportActionID; - const reportScrollManager = useReportScrollManager(); - const isActionableWhisper = - ReportActionsUtils.isActionableMentionWhisper(action) || ReportActionsUtils.isActionableTrackExpense(action) || ReportActionsUtils.isActionableReportMentionWhisper(action); - const originalMessage = ReportActionsUtils.getOriginalMessage(action); - - const highlightedBackgroundColorIfNeeded = useMemo( - () => (isReportActionLinked ? StyleUtils.getBackgroundColorStyle(theme.messageHighlightBG) : {}), - [StyleUtils, isReportActionLinked, theme.messageHighlightBG], - ); - - const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); - const isOriginalMessageAnObject = originalMessage && typeof originalMessage === 'object'; - const hasResolutionInOriginalMessage = isOriginalMessageAnObject && 'resolution' in originalMessage; - const prevActionResolution = usePrevious(isActionableWhisper && hasResolutionInOriginalMessage ? originalMessage?.resolution : null); - - // IOUDetails only exists when we are sending money - const isSendingMoney = - ReportActionsUtils.isMoneyRequestAction(action) && - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && - ReportActionsUtils.getOriginalMessage(action)?.IOUDetails; - - const updateHiddenState = useCallback( - (isHiddenValue: boolean) => { - setIsHidden(isHiddenValue); - const message = Array.isArray(action.message) ? action.message?.at(-1) : action.message; - const isAttachment = ReportUtils.isReportMessageAttachment(message); - if (!isAttachment) { - return; - } - updateHiddenAttachments(action.reportActionID, isHiddenValue); - }, - [action.reportActionID, action.message, updateHiddenAttachments], - ); - - useEffect( - () => () => { - // ReportActionContextMenu, EmojiPicker and PopoverReactionList are global components, - // we should also hide them when the current component is destroyed - if (ReportActionContextMenu.isActiveReportAction(action.reportActionID)) { - ReportActionContextMenu.hideContextMenu(); - ReportActionContextMenu.hideDeleteModal(); - } - if (EmojiPickerAction.isActive(action.reportActionID)) { - EmojiPickerAction.hideEmojiPicker(true); - } - if (reactionListRef?.current?.isActiveReportAction(action.reportActionID)) { - reactionListRef?.current?.hideReactionList(); - } - }, - [action.reportActionID, reactionListRef], - ); - - useEffect(() => { - // We need to hide EmojiPicker when this is a deleted parent action - if (!isDeletedParentAction || !EmojiPickerAction.isActive(action.reportActionID)) { - return; - } - - EmojiPickerAction.hideEmojiPicker(true); - }, [isDeletedParentAction, action.reportActionID]); - - useEffect(() => { - if (prevDraftMessage !== undefined || draftMessage === undefined) { - return; - } - - focusComposerWithDelay(textInputRef.current)(true); - }, [prevDraftMessage, draftMessage]); - - useEffect(() => { - if (!Permissions.canUseLinkPreviews()) { - return; - } - - const urls = ReportActionsUtils.extractLinksFromMessageHtml(action); - if (lodashIsEqual(downloadedPreviews.current, urls) || action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { - return; - } - - downloadedPreviews.current = urls; - Report.expandURLPreview(reportID, action.reportActionID); - }, [action, reportID]); - - useEffect(() => { - if (draftMessage === undefined || !ReportActionsUtils.isDeletedAction(action)) { - return; - } - Report.deleteReportActionDraft(reportID, action); - }, [draftMessage, action, reportID]); - - // Hide the message if it is being moderated for a higher offense, or is hidden by a moderator - // Removed messages should not be shown anyway and should not need this flow - const latestDecision = ReportActionsUtils.getReportActionMessage(action)?.moderationDecision?.decision ?? ''; - useEffect(() => { - if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT) { - return; - } - - // Hide reveal message button and show the message if latestDecision is changed to empty - if (!latestDecision) { - setModerationDecision(CONST.MODERATION.MODERATOR_DECISION_APPROVED); - setIsHidden(false); - return; - } - - setModerationDecision(latestDecision); - if ( - ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && - !ReportActionsUtils.isPendingRemove(action) - ) { - setIsHidden(true); - return; - } - setIsHidden(false); - }, [latestDecision, action]); - - const toggleContextMenuFromActiveReportAction = useCallback(() => { - setIsContextMenuActive(ReportActionContextMenu.isActiveReportAction(action.reportActionID)); - }, [action.reportActionID]); - - const isArchivedRoom = ReportUtils.isArchivedRoomWithID(originalReportID); - const disabledActions = useMemo(() => (!ReportUtils.canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]); - const isChronosReport = ReportUtils.chatIncludesChronosWithID(originalReportID); - /** - * Show the ReportActionContextMenu modal popover. - * - * @param [event] - A press event. - */ - const showPopover = useCallback( - (event: GestureResponderEvent | MouseEvent) => { - // Block menu on the message being Edited or if the report action item has errors - if (draftMessage !== undefined || !isEmptyObject(action.errors) || !shouldDisplayContextMenu) { - return; - } - - setIsContextMenuActive(true); - const selection = SelectionScraper.getCurrentSelection(); - ReportActionContextMenu.showContextMenu( - CONST.CONTEXT_MENU_TYPES.REPORT_ACTION, - event, - selection, - popoverAnchorRef.current, - reportID, - action.reportActionID, - originalReportID, - draftMessage ?? '', - () => setIsContextMenuActive(true), - toggleContextMenuFromActiveReportAction, - isArchivedRoom, - isChronosReport, - false, - false, - disabledActions, - false, - setIsEmojiPickerActive as () => void, - undefined, - isThreadReportParentAction, - ); - }, - [ - draftMessage, - action, - reportID, - toggleContextMenuFromActiveReportAction, - originalReportID, - shouldDisplayContextMenu, - disabledActions, - isArchivedRoom, - isChronosReport, - isThreadReportParentAction, - ], - ); - - // Handles manual scrolling to the bottom of the chat when the last message is an actionable whisper and it's resolved. - // This fixes an issue where InvertedFlatList fails to auto scroll down and results in an empty space at the bottom of the chat in IOS. - useEffect(() => { - if (index !== 0 || !isActionableWhisper) { - return; - } - - if (prevActionResolution !== (hasResolutionInOriginalMessage ? originalMessage.resolution : null)) { - reportScrollManager.scrollToIndex(index); - } - }, [index, originalMessage, prevActionResolution, reportScrollManager, isActionableWhisper, hasResolutionInOriginalMessage]); - - const toggleReaction = useCallback( - (emoji: Emoji, ignoreSkinToneOnCompare?: boolean) => { - Report.toggleEmojiReaction(reportID, action, emoji, emojiReactions, undefined, ignoreSkinToneOnCompare); - }, - [reportID, action, emojiReactions], - ); - - const contextValue = useMemo( - () => ({ - anchor: popoverAnchorRef.current, - report: {...report, reportID: report?.reportID ?? ''}, - reportNameValuePairs, - action, - transactionThreadReport, - checkIfContextMenuActive: toggleContextMenuFromActiveReportAction, - isDisabled: false, - }), - [report, action, toggleContextMenuFromActiveReportAction, transactionThreadReport, reportNameValuePairs], - ); - - const attachmentContextValue = useMemo(() => ({reportID, type: CONST.ATTACHMENT_TYPE.REPORT}), [reportID]); - - const mentionReportContextValue = useMemo(() => ({currentReportID: report?.reportID ?? '-1'}), [report?.reportID]); - - const actionableItemButtons: ActionableItem[] = useMemo(() => { - if (ReportActionsUtils.isActionableAddPaymentCard(action) && userBillingFundID === undefined && shouldRenderAddPaymentCard()) { - return [ - { - text: 'subscription.cardSection.addCardButton', - key: `${action.reportActionID}-actionableAddPaymentCard-submit`, - onPress: () => { - Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION_ADD_PAYMENT_CARD); - }, - isMediumSized: true, - isPrimary: true, - }, - ]; - } - - if (!isActionableWhisper && (!ReportActionsUtils.isActionableJoinRequest(action) || ReportActionsUtils.getOriginalMessage(action)?.choice !== ('' as JoinWorkspaceResolution))) { - return []; - } - - if (ReportActionsUtils.isActionableTrackExpense(action)) { - const transactionID = ReportActionsUtils.getOriginalMessage(action)?.transactionID; - return [ - { - text: 'actionableMentionTrackExpense.submit', - key: `${action.reportActionID}-actionableMentionTrackExpense-submit`, - onPress: () => { - ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID); - }, - isMediumSized: true, - }, - { - text: 'actionableMentionTrackExpense.categorize', - key: `${action.reportActionID}-actionableMentionTrackExpense-categorize`, - onPress: () => { - ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.CATEGORIZE, action.reportActionID); - }, - isMediumSized: true, - }, - { - text: 'actionableMentionTrackExpense.share', - key: `${action.reportActionID}-actionableMentionTrackExpense-share`, - onPress: () => { - ReportUtils.createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.SHARE, action.reportActionID); - }, - isMediumSized: true, - }, - { - text: 'actionableMentionTrackExpense.nothing', - key: `${action.reportActionID}-actionableMentionTrackExpense-nothing`, - onPress: () => { - Report.dismissTrackExpenseActionableWhisper(reportID, action); - }, - isMediumSized: true, - }, - ]; - } - - if (ReportActionsUtils.isActionableJoinRequest(action)) { - return [ - { - text: 'actionableMentionJoinWorkspaceOptions.accept', - key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT}`, - onPress: () => Member.acceptJoinRequest(reportID, action), - isPrimary: true, - }, - { - text: 'actionableMentionJoinWorkspaceOptions.decline', - key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE}`, - onPress: () => Member.declineJoinRequest(reportID, action), - }, - ]; - } - - if (ReportActionsUtils.isActionableReportMentionWhisper(action)) { - return [ - { - text: 'common.yes', - key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE}`, - onPress: () => Report.resolveActionableReportMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.CREATE), - isPrimary: true, - }, - { - text: 'common.no', - key: `${action.reportActionID}-actionableReportMentionWhisper-${CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING}`, - onPress: () => Report.resolveActionableReportMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_REPORT_MENTION_WHISPER_RESOLUTION.NOTHING), - }, - ]; - } - - return [ - { - text: 'actionableMentionWhisperOptions.invite', - key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE}`, - onPress: () => Report.resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE), - isPrimary: true, - }, - { - text: 'actionableMentionWhisperOptions.nothing', - key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING}`, - onPress: () => Report.resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING), - }, - ]; - }, [action, isActionableWhisper, reportID, userBillingFundID]); - - /** - * Get the content of ReportActionItem - * @param hovered whether the ReportActionItem is hovered - * @param isWhisper whether the report action is a whisper - * @param hasErrors whether the report action has any errors - * @returns child component(s) - */ - const renderItemContent = (hovered = false, isWhisper = false, hasErrors = false): React.JSX.Element => { - let children; - - // Show the MoneyRequestPreview for when expense is present - if ( - ReportActionsUtils.isMoneyRequestAction(action) && - ReportActionsUtils.getOriginalMessage(action) && - // For the pay flow, we only want to show MoneyRequestAction when sending money. When paying, we display a regular system message - (ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE || - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT || - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) - ) { - // There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID - const iouReportID = ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ? ReportActionsUtils.getOriginalMessage(action)?.IOUReportID?.toString() ?? '-1' : '-1'; - children = ( - - ); - } else if (ReportActionsUtils.isTripPreview(action)) { - children = ( - - ); - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) { - children = ReportUtils.isClosedExpenseReportWithNoExpenses(iouReport) ? ( - ${translate('parentReportAction.deletedReport')}`} /> - ) : ( - setIsPaymentMethodPopoverActive(true)} - onPaymentOptionsHide={() => setIsPaymentMethodPopoverActive(false)} - isWhisper={isWhisper} - /> - ); - } else if (ReportActionsUtils.isTaskAction(action)) { - children = ; - } else if (ReportActionsUtils.isCreatedTaskReportAction(action)) { - children = ( - - - - ); - } else if (ReportActionsUtils.isReimbursementQueuedAction(action)) { - const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; - const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails[linkedReport?.ownerAccountID ?? -1]); - const paymentType = ReportActionsUtils.getOriginalMessage(action)?.paymentType ?? ''; - - const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID ?? '-1', action); - children = ( - - <> - {missingPaymentMethod === 'bankAccount' && ( - - )} - {/** - These are the actionable buttons that appear at the bottom of a Concierge message - for example: Invite a user mentioned but not a member of the room - https://github.com/Expensify/App/issues/32741 - */} - {actionableItemButtons.length > 0 && ( - - )} - - ) : ( - - )} - - - - ); - } - const numberOfThreadReplies = action.childVisibleActionCount ?? 0; - - const shouldDisplayThreadReplies = ReportUtils.shouldDisplayThreadReplies(action, isThreadReportParentAction); - const oldestFourAccountIDs = - action.childOldestFourAccountIDs - ?.split(',') - .map((accountID) => Number(accountID)) - .filter((accountID): accountID is number => typeof accountID === 'number') ?? []; - const draftMessageRightAlign = draftMessage !== undefined ? styles.chatItemReactionsDraftRight : {}; - - return ( - <> - {children} - {Permissions.canUseLinkPreviews() && !isHidden && (action.linkMetadata?.length ?? 0) > 0 && ( - - !isEmptyObject(item))} /> - - )} - {!ReportActionsUtils.isMessageDeleted(action) && ( - - { - if (Session.isAnonymousUser()) { - hideContextMenu(false); - - InteractionManager.runAfterInteractions(() => { - Session.signOutAndRedirectToSignIn(); - }); - } else { - toggleReaction(emoji, ignoreSkinToneOnCompare); - } - }} - setIsEmojiPickerActive={setIsEmojiPickerActive} - /> - - )} - - {shouldDisplayThreadReplies && ( - - - - )} - - ); - }; - - /** - * Get ReportActionItem with a proper wrapper - * @param hovered whether the ReportActionItem is hovered - * @param isWhisper whether the ReportActionItem is a whisper - * @param hasErrors whether the report action has any errors - * @returns report action item - */ - - const renderReportActionItem = (hovered: boolean, isWhisper: boolean, hasErrors: boolean): React.JSX.Element => { - const content = renderItemContent(hovered || isContextMenuActive || isEmojiPickerActive, isWhisper, hasErrors); - - if (draftMessage !== undefined) { - return {content}; - } - - if (!displayAsGroup) { - return ( - item === moderationDecision) && - !ReportActionsUtils.isPendingRemove(action) - } - > - {content} - - ); - } - - return {content}; - }; - - if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { - const transactionID = ReportActionsUtils.isMoneyRequestAction(parentReportActionForTransactionThread) - ? ReportActionsUtils.getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID - : '-1'; - - return ( - - ); - } - if (ReportActionsUtils.isChronosOOOListAction(action)) { - return ( - - ); - } - - // For the `pay` IOU action on non-pay expense flow, we don't want to render anything if `isWaitingOnBankAccount` is true - // Otherwise, we will see two system messages informing the payee needs to add a bank account or wallet - if ( - ReportActionsUtils.isMoneyRequestAction(action) && - !!report?.isWaitingOnBankAccount && - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && - !isSendingMoney - ) { - return null; - } - - // If action is actionable whisper and resolved by user, then we don't want to render anything - if (isActionableWhisper && (hasResolutionInOriginalMessage ? originalMessage.resolution : null)) { - return null; - } - - // We currently send whispers to all report participants and hide them in the UI for users that shouldn't see them. - // This is a temporary solution needed for comment-linking. - // The long term solution will leverage end-to-end encryption and only targeted users will be able to decrypt. - if (ReportActionsUtils.isWhisperActionTargetedToOthers(action)) { - return null; - } - - const hasErrors = !isEmptyObject(action.errors); - const whisperedTo = ReportActionsUtils.getWhisperedTo(action); - const isMultipleParticipant = whisperedTo.length > 1; - - const iouReportID = - ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUReportID - ? (ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ?? '').toString() - : '-1'; - const transactionsWithReceipts = ReportUtils.getTransactionsWithReceipts(iouReportID); - const isWhisper = whisperedTo.length > 0 && transactionsWithReceipts.length === 0; - const whisperedToPersonalDetails = isWhisper - ? (Object.values(personalDetails ?? {}).filter((details) => whisperedTo.includes(details?.accountID ?? -1)) as OnyxTypes.PersonalDetails[]) - : []; - const isWhisperOnlyVisibleByUser = isWhisper && ReportUtils.isCurrentUserTheOnlyParticipant(whisperedTo); - const displayNamesWithTooltips = isWhisper ? ReportUtils.getDisplayNamesWithTooltips(whisperedToPersonalDetails, isMultipleParticipant) : []; + const personalDetails = usePersonalDetails(); + const blockedFromConcierge = useBlockedFromConcierge(); + const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID); + const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; + const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID ?? '-1', action); return ( - shouldUseNarrowLayout && DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} - onPressOut={() => ControlSelection.unblock()} - onSecondaryInteraction={showPopover} - preventDefaultContextMenu={draftMessage === undefined && !hasErrors} - withoutFocusOnSecondaryInteraction - accessibilityLabel={translate('accessibilityHints.chatMessage')} - accessible - > - - {(hovered) => ( - - {shouldDisplayNewMarker && (!shouldUseThreadDividerLine || !isFirstVisibleReportAction) && } - {shouldDisplayContextMenu && ( - - )} - - { - const transactionID = ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID : undefined; - if (transactionID) { - Transaction.clearError(transactionID); - } - ReportActions.clearAllRelatedReportActionErrors(reportID, action); - }} - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - pendingAction={ - draftMessage !== undefined ? undefined : action.pendingAction ?? (action.isOptimisticAction ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : undefined) - } - shouldHideOnDelete={!ReportActionsUtils.isThreadParentMessage(action, reportID)} - errors={linkedTransactionRouteError ?? ErrorUtils.getLatestErrorMessageField(action as ErrorUtils.OnyxDataWithErrors)} - errorRowStyles={[styles.ml10, styles.mr2]} - needsOffscreenAlphaCompositing={ReportActionsUtils.isMoneyRequestAction(action)} - shouldDisableStrikeThrough - > - {isWhisper && ( - - - - - - {translate('reportActionContextMenu.onlyVisible')} -   - - - - )} - {renderReportActionItem(!!hovered || !!isReportActionLinked, isWhisper, hasErrors)} - - - - )} - - - - - + >, + report, + )} + modifiedExpenseMessage={ModifiedExpenseMessage.getForReportAction(reportID, action)} + getTransactionsWithReceipts={ReportUtils.getTransactionsWithReceipts} + clearError={Transaction.clearError} + clearAllRelatedReportActionErrors={ReportActions.clearAllRelatedReportActionErrors} + dismissTrackExpenseActionableWhisper={Report.dismissTrackExpenseActionableWhisper} + userBillingFundID={userBillingFundID} + reportAutomaticallyForwardedMessage={ReportUtils.getReportAutomaticallyForwardedMessage(action as ReportAction, reportID)} + /> ); } -export default memo(ReportActionItem, (prevProps, nextProps) => { - const prevParentReportAction = prevProps.parentReportAction; - const nextParentReportAction = nextProps.parentReportAction; - return ( - prevProps.displayAsGroup === nextProps.displayAsGroup && - prevProps.isMostRecentIOUReportAction === nextProps.isMostRecentIOUReportAction && - prevProps.shouldDisplayNewMarker === nextProps.shouldDisplayNewMarker && - lodashIsEqual(prevProps.action, nextProps.action) && - lodashIsEqual(prevProps.report?.pendingFields, nextProps.report?.pendingFields) && - lodashIsEqual(prevProps.report?.isDeletedParentAction, nextProps.report?.isDeletedParentAction) && - lodashIsEqual(prevProps.report?.errorFields, nextProps.report?.errorFields) && - prevProps.report?.statusNum === nextProps.report?.statusNum && - prevProps.report?.stateNum === nextProps.report?.stateNum && - prevProps.report?.parentReportID === nextProps.report?.parentReportID && - prevProps.report?.parentReportActionID === nextProps.report?.parentReportActionID && - // TaskReport's created actions render the TaskView, which updates depending on certain fields in the TaskReport - ReportUtils.isTaskReport(prevProps.report) === ReportUtils.isTaskReport(nextProps.report) && - prevProps.action.actionName === nextProps.action.actionName && - prevProps.report?.reportName === nextProps.report?.reportName && - prevProps.report?.description === nextProps.report?.description && - ReportUtils.isCompletedTaskReport(prevProps.report) === ReportUtils.isCompletedTaskReport(nextProps.report) && - prevProps.report?.managerID === nextProps.report?.managerID && - prevProps.shouldHideThreadDividerLine === nextProps.shouldHideThreadDividerLine && - prevProps.report?.total === nextProps.report?.total && - prevProps.report?.nonReimbursableTotal === nextProps.report?.nonReimbursableTotal && - prevProps.report?.policyAvatar === nextProps.report?.policyAvatar && - prevProps.linkedReportActionID === nextProps.linkedReportActionID && - lodashIsEqual(prevProps.report?.fieldList, nextProps.report?.fieldList) && - lodashIsEqual(prevProps.transactionThreadReport, nextProps.transactionThreadReport) && - lodashIsEqual(prevProps.reportActions, nextProps.reportActions) && - lodashIsEqual(prevParentReportAction, nextParentReportAction) - ); -}); +export default ReportActionItem; From f086d7c2053f290006b7f65dbcc73d25c91057f5 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sat, 14 Dec 2024 16:22:52 +0530 Subject: [PATCH 10/38] update changes in PureReportActionItem. Signed-off-by: krishna2323 --- src/pages/home/report/PureReportActionItem.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 34dd2a9d1350..0194260ec667 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -818,13 +818,28 @@ function PureReportActionItem({ } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { - children = ; + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + children = ; + } else if ( + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME + ) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { + children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; } else if ( From 404a38254abe4a7ed5fadf4340fef0b0aaf2f103 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Dec 2024 08:52:50 +0530 Subject: [PATCH 11/38] add translation for UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT & PREVENT_SELF_APPROVAL change logs. Signed-off-by: krishna2323 --- src/CONST.ts | 3 +++ src/languages/en.ts | 6 +++++ src/languages/es.ts | 6 +++++ src/languages/params.ts | 6 +++++ src/libs/ReportActionsUtils.ts | 23 +++++++++++++++++++ src/libs/SidebarUtils.ts | 6 +++-- .../report/ContextMenu/ContextMenuActions.tsx | 6 +++-- .../home/report/PureReportActionItem.tsx | 6 +++-- src/types/onyx/OriginalMessage.ts | 9 ++++++++ 9 files changed, 65 insertions(+), 6 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 1feab5f29bd2..cbd54c9a4e5f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2581,6 +2581,9 @@ const CONST = { AUTOREPORTING_OFFSET: 'autoReportingOffset', GENERAL_SETTINGS: 'generalSettings', }, + EXPENSE_REPORT_RULES: { + PREVENT_SELF_APPROVAL: 'preventSelfApproval', + }, CONNECTIONS: { NAME: { // Here we will add other connections names when we add support for them diff --git a/src/languages/en.ts b/src/languages/en.ts index 04ad63113d8c..43b290dd9a68 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -170,6 +170,8 @@ import type { UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, UpdatedPolicyFrequencyParams, + UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -4467,6 +4469,10 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, + preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => + `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountNoReceiptParams) => + `changed the maximum receipt required expense amount from ${oldValue} to ${newValue}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/es.ts b/src/languages/es.ts index 0b6e2b29f186..43253f26bf25 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -169,6 +169,8 @@ import type { UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, UpdatedPolicyFrequencyParams, + UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -4516,6 +4518,10 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, + preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => + `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountNoReceiptParams) => + `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index a5603835aaba..4529fe3ebab2 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -292,6 +292,10 @@ type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; +type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; + +type UpdatedPolicyMaxExepenseAmountNoReceiptParams = {oldValue: string; newValue: string}; + type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; type ChangeTypeParams = {oldType: string; newType: string}; @@ -800,4 +804,6 @@ export type { UpdatedPolicyFrequencyParams, UpdatedPolicyCategoryParams, UpdatedPolicyCategoryNameParams, + UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyMaxExepenseAmountNoReceiptParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 6792228130d4..8dfaca55c929 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -16,6 +16,7 @@ import type ReportAction from '@src/types/onyx/ReportAction'; import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction'; import type ReportActionName from '@src/types/onyx/ReportActionName'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import * as CurrencyUtils from './CurrencyUtils'; import DateUtils from './DateUtils'; import * as Environment from './Environment/Environment'; import getBase62ReportID from './getBase62ReportID'; @@ -1830,6 +1831,27 @@ function getWorkspaceUpdateFieldMessage(action: ReportAction): string { }); } + if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.PREVENT_SELF_APPROVAL && typeof oldValue === 'string' && typeof newValue === 'string') { + return Localize.translateLocal('workspaceActions.preventSelfApproval', { + oldValue, + newValue, + }); + } + + return getReportActionText(action); +} + +function getPolicyChangeLogMaxAmmountNoReceiptMessage(action: ReportAction): string { + const {oldMaxExpenseAmountNoReceipt, newMaxExpenseAmountNoReceipt, currency} = + getOriginalMessage(action as ReportAction) ?? {}; + + if (typeof oldMaxExpenseAmountNoReceipt === 'number' && typeof newMaxExpenseAmountNoReceipt === 'number') { + return Localize.translateLocal('workspaceActions.updateMaxExpenseAmountNoReceipt', { + oldValue: CurrencyUtils.convertToDisplayString(oldMaxExpenseAmountNoReceipt, currency), + newValue: CurrencyUtils.convertToDisplayString(newMaxExpenseAmountNoReceipt, currency), + }); + } + return getReportActionText(action); } @@ -2077,6 +2099,7 @@ export { getWorkspaceNameUpdatedMessage, getWorkspaceCurrencyUpdateMessage, getWorkspaceFrequencyUpdateMessage, + getPolicyChangeLogMaxAmmountNoReceiptMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index d6ee1e51d5dc..80d7925a0344 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -476,6 +476,10 @@ function getOptionData({ ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { + result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { + result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxAmmountNoReceiptMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { @@ -492,8 +496,6 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction); - } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index f21a0fb2a347..9610c9c195a1 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -425,6 +425,10 @@ const ContextMenuActions: ContextMenuAction[] = [ reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { + setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxAmmountNoReceiptMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { @@ -485,8 +489,6 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(reportAction)); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(reportAction) ?? {label: '', errorMessage: ''}; setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage})); diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 0194260ec667..f959eecae980 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -832,14 +832,16 @@ function PureReportActionItem({ action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { + children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { - children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; } else if ( diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 2d64e4c0b315..1600c95b1c07 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -338,6 +338,15 @@ type OriginalMessagePolicyChangeLog = { /** Name of the updated field */ updatedField?: string; + + /** Old value for max expense amount with no receipt */ + oldMaxExpenseAmountNoReceipt?: number; + + /** New value for max expense amount with no receipt */ + newMaxExpenseAmountNoReceipt?: number; + + /** Currency of the policy */ + currency?: string; }; /** Model of `join policy changelog` report action */ From a25ffafe25ae58f23b19747980dcaf96d70fea63 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Dec 2024 09:26:41 +0530 Subject: [PATCH 12/38] add translations form UPDATE_MAX_EXPENSE_AMOUNT & MAX_EXPENSE_AGE. Signed-off-by: krishna2323 --- src/CONST.ts | 1 + src/languages/en.ts | 7 +++-- src/languages/es.ts | 8 +++--- src/languages/params.ts | 4 +-- src/libs/ReportActionsUtils.ts | 26 +++++++++++++++++-- src/libs/SidebarUtils.ts | 4 ++- .../report/ContextMenu/ContextMenuActions.tsx | 4 ++- .../home/report/PureReportActionItem.tsx | 4 ++- src/types/onyx/OriginalMessage.ts | 6 +++++ 9 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index cbd54c9a4e5f..397b4fe905f1 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2583,6 +2583,7 @@ const CONST = { }, EXPENSE_REPORT_RULES: { PREVENT_SELF_APPROVAL: 'preventSelfApproval', + MAX_EXPENSE_AGE: 'maxExpenseAge', }, CONNECTIONS: { NAME: { diff --git a/src/languages/en.ts b/src/languages/en.ts index 43b290dd9a68..4a8074f41adf 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -170,7 +170,7 @@ import type { UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, UpdatedPolicyFrequencyParams, - UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyMaxExepenseAmountParams, UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, @@ -4471,8 +4471,11 @@ const translations = { setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, - updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountNoReceiptParams) => + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `changed the maximum receipt required expense amount from ${oldValue} to ${newValue}`, + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `changed the maximum expense amount for violations from ${oldValue} to ${newValue}`, + updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + `updated "Max Expense Age (Days)" from "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" to "${newValue}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/es.ts b/src/languages/es.ts index 43253f26bf25..13a5db13c717 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -169,7 +169,7 @@ import type { UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, UpdatedPolicyFrequencyParams, - UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyMaxExepenseAmountParams, UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, @@ -4520,8 +4520,10 @@ const translations = { setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, - updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountNoReceiptParams) => - `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `cambió el monto máximo de gasto para violaciones de ${oldValue} a ${newValue}`, + updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + `actualizó "Antigüedad Máxima de Gastos (días)" de "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" a "${newValue}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index 4529fe3ebab2..fc0c32a9eb4b 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -294,7 +294,7 @@ type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; -type UpdatedPolicyMaxExepenseAmountNoReceiptParams = {oldValue: string; newValue: string}; +type UpdatedPolicyMaxExepenseAmountParams = {oldValue: string; newValue: string}; type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; @@ -805,5 +805,5 @@ export type { UpdatedPolicyCategoryParams, UpdatedPolicyCategoryNameParams, UpdatedPolicyPreventSelfApprovalParams, - UpdatedPolicyMaxExepenseAmountNoReceiptParams, + UpdatedPolicyMaxExepenseAmountParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 8dfaca55c929..5ec1e5c4efdb 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1838,10 +1838,17 @@ function getWorkspaceUpdateFieldMessage(action: ReportAction): string { }); } + if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.MAX_EXPENSE_AGE && typeof oldValue === 'string' && typeof newValue === 'string') { + return Localize.translateLocal('workspaceActions.updateMaxExpenseAge', { + oldValue, + newValue, + }); + } + return getReportActionText(action); } -function getPolicyChangeLogMaxAmmountNoReceiptMessage(action: ReportAction): string { +function getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(action: ReportAction): string { const {oldMaxExpenseAmountNoReceipt, newMaxExpenseAmountNoReceipt, currency} = getOriginalMessage(action as ReportAction) ?? {}; @@ -1855,6 +1862,20 @@ function getPolicyChangeLogMaxAmmountNoReceiptMessage(action: ReportAction): str return getReportActionText(action); } +function getPolicyChangeLogMaxExpenseAmountMessage(action: ReportAction): string { + const {oldMaxExpenseAmount, newMaxExpenseAmount, currency} = + getOriginalMessage(action as ReportAction) ?? {}; + + if (typeof oldMaxExpenseAmount === 'number' && typeof newMaxExpenseAmount === 'number') { + return Localize.translateLocal('workspaceActions.updateMaxExpenseAmount', { + oldValue: CurrencyUtils.convertToDisplayString(oldMaxExpenseAmount, currency), + newValue: CurrencyUtils.convertToDisplayString(newMaxExpenseAmount, currency), + }); + } + + return getReportActionText(action); +} + function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogDeleteMemberMessage(reportAction)) { return ''; @@ -2099,7 +2120,8 @@ export { getWorkspaceNameUpdatedMessage, getWorkspaceCurrencyUpdateMessage, getWorkspaceFrequencyUpdateMessage, - getPolicyChangeLogMaxAmmountNoReceiptMessage, + getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, + getPolicyChangeLogMaxExpenseAmountMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 80d7925a0344..96d3af9952f2 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -479,7 +479,9 @@ function getOptionData({ } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxAmmountNoReceiptMessage(lastAction); + result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { + result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 9610c9c195a1..c8a7e1ebcae0 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -428,7 +428,9 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { - Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxAmmountNoReceiptMessage(reportAction)); + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index f959eecae980..359b6b7832c5 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -835,7 +835,9 @@ function PureReportActionItem({ } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { - children = ; + children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 1600c95b1c07..3cea305cb05b 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -347,6 +347,12 @@ type OriginalMessagePolicyChangeLog = { /** Currency of the policy */ currency?: string; + + /** Old value for max expense amount for violations */ + oldMaxExpenseAmount?: number; + + /** New value for max expense amount for violations */ + newMaxExpenseAmount?: number; }; /** Model of `join policy changelog` report action */ From ea07da4eea1d1667d0be597768a6914f66d1ae99 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Dec 2024 09:55:31 +0530 Subject: [PATCH 13/38] add translations form UPDATE_DEFAULT_TITLE_ENFORCED & UPDATE_DEFAULT_BILLABLE. Signed-off-by: krishna2323 --- src/languages/en.ts | 3 ++- src/languages/es.ts | 12 ++++++--- src/languages/params.ts | 7 +++-- src/libs/ReportActionsUtils.ts | 27 +++++++++++++++++++ src/libs/SidebarUtils.ts | 4 +++ .../report/ContextMenu/ContextMenuActions.tsx | 4 +++ .../home/report/PureReportActionItem.tsx | 4 +++ src/types/onyx/OriginalMessage.ts | 9 +++++++ 8 files changed, 63 insertions(+), 7 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 4a8074f41adf..fe9878b554e7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -169,8 +169,9 @@ import type { UpdatedPolicyCategoryNameParams, UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, - UpdatedPolicyMaxExepenseAmountParams, UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, diff --git a/src/languages/es.ts b/src/languages/es.ts index 13a5db13c717..95de3fee6030 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -168,8 +168,9 @@ import type { UpdatedPolicyCategoryNameParams, UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, - UpdatedPolicyMaxExepenseAmountParams, UpdatedPolicyPreventSelfApprovalParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, @@ -4520,10 +4521,13 @@ const translations = { setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, - updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, - updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `cambió el monto máximo de gasto para violaciones de ${oldValue} a ${newValue}`, - updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => + `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `cambió el monto máximo de gasto para violaciones de ${oldValue} a ${newValue}`, + updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `actualizó "Antigüedad Máxima de Gastos (días)" de "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" a "${newValue}"`, + updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `actualizó "Refacturar gastos a clientes" de "${oldValue}" a "${newValue}"`, + updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `cambió "Aplicar título predeterminado de informe" a ${value ? 'activado' : 'desactivado'}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index fc0c32a9eb4b..e4b2a754a5b3 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -294,7 +294,9 @@ type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; -type UpdatedPolicyMaxExepenseAmountParams = {oldValue: string; newValue: string}; +type UpdatedPolicyFieldWithNewAndOldValueParams = {oldValue: string; newValue: string}; + +type UpdatedPolicyFieldWithValueParam = {value: boolean}; type UpdatedPolicyFrequencyParams = {oldFrequency: string; newFrequency: string}; @@ -805,5 +807,6 @@ export type { UpdatedPolicyCategoryParams, UpdatedPolicyCategoryNameParams, UpdatedPolicyPreventSelfApprovalParams, - UpdatedPolicyMaxExepenseAmountParams, + UpdatedPolicyFieldWithNewAndOldValueParams, + UpdatedPolicyFieldWithValueParam, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 5ec1e5c4efdb..fa100b7ebf0f 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1876,6 +1876,31 @@ function getPolicyChangeLogMaxExpenseAmountMessage(action: ReportAction): string return getReportActionText(action); } +function getPolicyChangeLogDefaultBillableMessage(action: ReportAction): string { + const {oldDefaultBillable, newDefaultBillable} = getOriginalMessage(action as ReportAction) ?? {}; + + if (typeof oldDefaultBillable === 'string' && typeof newDefaultBillable === 'string') { + return Localize.translateLocal('workspaceActions.updateDefaultBillable', { + oldValue: oldDefaultBillable, + newValue: newDefaultBillable, + }); + } + + return getReportActionText(action); +} + +function getPolicyChangeLogDefaultTitleEnforcedMessage(action: ReportAction): string { + const {value} = getOriginalMessage(action as ReportAction) ?? {}; + + if (typeof value === 'boolean') { + return Localize.translateLocal('workspaceActions.updateDefaultTitleEnforced', { + value, + }); + } + + return getReportActionText(action); +} + function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogDeleteMemberMessage(reportAction)) { return ''; @@ -2122,6 +2147,8 @@ export { getWorkspaceFrequencyUpdateMessage, getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, getPolicyChangeLogMaxExpenseAmountMessage, + getPolicyChangeLogDefaultBillableMessage, + getPolicyChangeLogDefaultTitleEnforcedMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 96d3af9952f2..d5fe17934b2a 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -482,6 +482,10 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE) { + result.alternateText = ReportActionsUtils.getPolicyChangeLogDefaultBillableMessage(lastAction); + } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED) { + result.alternateText = ReportActionsUtils.getPolicyChangeLogDefaultTitleEnforcedMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index c8a7e1ebcae0..d515fe80a0ae 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -431,6 +431,10 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE) { + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogDefaultBillableMessage(reportAction)); + } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED) { + Clipboard.setString(ReportActionsUtils.getPolicyChangeLogDefaultTitleEnforcedMessage(reportAction)); } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { Clipboard.setString(ReportUtils.getReimbursementQueuedActionMessage(reportAction, reportID, false)); } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 359b6b7832c5..5d52d4b9bb11 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -838,6 +838,10 @@ function PureReportActionItem({ children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) { children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE)) { + children = ; + } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 3cea305cb05b..a90e322da80d 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -353,6 +353,15 @@ type OriginalMessagePolicyChangeLog = { /** New value for max expense amount for violations */ newMaxExpenseAmount?: number; + + /** Old default billable value */ + oldDefaultBillable?: string; + + /** New default billable value */ + newDefaultBillable?: string; + + /** value -- returned when updating "Auto-approve compliant reports" */ + value?: boolean; }; /** Model of `join policy changelog` report action */ From 4d164058ca4983d6845a1478673811c5f8e26d74 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Dec 2024 09:55:52 +0530 Subject: [PATCH 14/38] minor update. Signed-off-by: krishna2323 --- src/languages/en.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index fe9878b554e7..9edb87cee7c9 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4472,11 +4472,13 @@ const translations = { setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, - updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `changed the maximum receipt required expense amount from ${oldValue} to ${newValue}`, - updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => `changed the maximum expense amount for violations from ${oldValue} to ${newValue}`, - updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyMaxExepenseAmountParams) => + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `changed the maximum expense amount for violations from ${oldValue} to ${newValue}`, + updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `updated "Max Expense Age (Days)" from "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" to "${newValue}"`, + updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `updated "Re-bill expenses to clients" from "${oldValue}" to "${newValue}"`, + updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `turned "Enforce Default Report Title" ${value ? 'on' : 'off'}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; From e6552f5325fd190111433dc22c0bb5a45ce22f85 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 7 Jan 2025 17:19:50 +0530 Subject: [PATCH 15/38] add translation for description update. Signed-off-by: krishna2323 --- src/languages/en.ts | 3 +++ src/languages/es.ts | 5 +++++ src/languages/params.ts | 3 +++ src/libs/ReportActionsUtils.ts | 10 ++++++++++ src/libs/SidebarUtils.ts | 2 ++ .../home/report/ContextMenu/ContextMenuActions.tsx | 2 ++ src/pages/home/report/PureReportActionItem.tsx | 2 ++ src/types/onyx/OriginalMessage.ts | 6 ++++++ 8 files changed, 33 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 12ce4ae6fa33..4ba028ab0373 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -174,6 +174,7 @@ import type { UpdatedPolicyCategoryNameParams, UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, + UpdatedPolicyDescriptionParams, UpdatedPolicyFieldWithNewAndOldValueParams, UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, @@ -4611,6 +4612,8 @@ const translations = { updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `updated "Re-bill expenses to clients" from "${oldValue}" to "${newValue}"`, updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `turned "Enforce Default Report Title" ${value ? 'on' : 'off'}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, + updateWorkspaceDescription: ({newDescription, oldDescription}: UpdatedPolicyDescriptionParams) => + !oldDescription ? `set the description of this workspace to "${newDescription}"` : `updated the description of this workspace from "${oldDescription}" to "${newDescription}"`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { diff --git a/src/languages/es.ts b/src/languages/es.ts index fa3e568daa80..ac54f332e062 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -173,6 +173,7 @@ import type { UpdatedPolicyCategoryNameParams, UpdatedPolicyCategoryParams, UpdatedPolicyCurrencyParams, + UpdatedPolicyDescriptionParams, UpdatedPolicyFieldWithNewAndOldValueParams, UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, @@ -4658,6 +4659,10 @@ const translations = { `actualizó "Antigüedad Máxima de Gastos (días)" de "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" a "${newValue}"`, updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `actualizó "Refacturar gastos a clientes" de "${oldValue}" a "${newValue}"`, updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `cambió "Aplicar título predeterminado de informe" a ${value ? 'activado' : 'desactivado'}`, + updateWorkspaceDescription: ({newDescription, oldDescription}: UpdatedPolicyDescriptionParams) => + !oldDescription + ? `estableció la descripción de este espacio de trabajo en "${newDescription}"` + : `actualizó la descripción de este espacio de trabajo de "${oldDescription}" a "${newDescription}"`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; diff --git a/src/languages/params.ts b/src/languages/params.ts index ea553433ddd1..7bdb79a4ae00 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -286,6 +286,8 @@ type ChangeFieldParams = {oldValue?: string; newValue: string; fieldName: string type ChangePolicyParams = {fromPolicy: string; toPolicy: string}; +type UpdatedPolicyDescriptionParams = {oldDescription: string; newDescription: string}; + type UpdatedPolicyCurrencyParams = {oldCurrency: string; newCurrency: string}; type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; @@ -835,6 +837,7 @@ export type { UpdatedPolicyPreventSelfApprovalParams, UpdatedPolicyFieldWithNewAndOldValueParams, UpdatedPolicyFieldWithValueParam, + UpdatedPolicyDescriptionParams, FirstDayTextParams, LastDayTextParams, TripLengthTextParams, diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 8ca670cf098a..cac5bfc3a553 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1762,6 +1762,15 @@ function getWorkspaceNameUpdatedMessage(action: ReportAction) { return message; } +function getWorkspaceDescriptionUpdatedMessage(action: ReportAction) { + const {oldDescription, newDescription} = getOriginalMessage(action as ReportAction) ?? {}; + const message = + typeof oldDescription === 'string' && newDescription + ? Localize.translateLocal('workspaceActions.updateWorkspaceDescription', {newDescription, oldDescription}) + : getReportActionText(action); + return message; +} + function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { const {oldCurrency, newCurrency} = getOriginalMessage(action as ReportAction) ?? {}; const message = oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : getReportActionText(action); @@ -2168,6 +2177,7 @@ export { getPolicyChangeLogMaxExpenseAmountMessage, getPolicyChangeLogDefaultBillableMessage, getPolicyChangeLogDefaultTitleEnforcedMessage, + getWorkspaceDescriptionUpdatedMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 63ac74048e6c..9333f1f83c25 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -473,6 +473,8 @@ function getOptionData({ result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`; } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { result.alternateText = ReportActionsUtils.getWorkspaceNameUpdatedMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION)) { + result.alternateText = ReportActionsUtils.getWorkspaceDescriptionUpdatedMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { result.alternateText = ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index b3e882db5087..58852e883cf8 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -413,6 +413,8 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(logMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { Clipboard.setString(ReportActionsUtils.getWorkspaceNameUpdatedMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION) { + Clipboard.setString(ReportActionsUtils.getWorkspaceDescriptionUpdatedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { Clipboard.setString(ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 637f7dcc6d2e..9a3be083a2cd 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -820,6 +820,8 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index a90e322da80d..5bd0d5e310f6 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -362,6 +362,12 @@ type OriginalMessagePolicyChangeLog = { /** value -- returned when updating "Auto-approve compliant reports" */ value?: boolean; + + /** New desciption */ + newDescription?: string; + + /** Old desciption */ + oldDescription?: string; }; /** Model of `join policy changelog` report action */ From d26e83a08341748c96fdca0296d0c781fc134710 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 7 Jan 2025 18:04:09 +0530 Subject: [PATCH 16/38] add translation for team downgrade policy change. Signed-off-by: krishna2323 --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/SidebarUtils.ts | 2 ++ src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 2 ++ src/pages/home/report/PureReportActionItem.tsx | 2 ++ 5 files changed, 8 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 4ba028ab0373..29333638b27e 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4631,6 +4631,7 @@ const translations = { updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, updatedWorkspaceCorporatePlan: 'upgraded this workspace to the Control plan', + updatedWorkspaceCorporatePlanDowngrade: 'downgraded this workspace to the Collect plan', updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `updated the Approval Mode from "${oldValue}" to "${newValue}".`, }, roomMembersPage: { diff --git a/src/languages/es.ts b/src/languages/es.ts index ac54f332e062..eb077bfcc1f7 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4682,6 +4682,7 @@ const translations = { updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, updatedWorkspaceCorporatePlan: 'mejoró este espacio de trabajo al plan Controlar', + updatedWorkspaceCorporatePlanDowngrade: 'degradó este espacio de trabajo al plan Collect', updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `Actualizó el Modo de Aprobación de "${oldValue}" a "${newValue}".`, }, roomMembersPage: { diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 9333f1f83c25..24a22bad988a 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -481,6 +481,8 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE)) { + result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlanDowngrade'); } else if ( ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 58852e883cf8..d6c982e0d166 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -421,6 +421,8 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { + Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlanDowngrade')); } else if ( reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 9a3be083a2cd..f4c064606ab8 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -828,6 +828,8 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { + children = ; } else if ( action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || From 206cb435c44dc321999851d273d35e12b0a44d02 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 7 Jan 2025 18:57:47 +0530 Subject: [PATCH 17/38] added report field addition policy change log translation. Signed-off-by: krishna2323 --- src/languages/en.ts | 2 ++ src/languages/es.ts | 2 ++ src/languages/params.ts | 3 +++ src/libs/ReportActionsUtils.ts | 14 ++++++++++++++ src/libs/SidebarUtils.ts | 2 ++ .../home/report/ContextMenu/ContextMenuActions.tsx | 2 ++ src/pages/home/report/PureReportActionItem.tsx | 2 ++ src/types/onyx/OriginalMessage.ts | 6 ++++++ 8 files changed, 33 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 29333638b27e..75f8c74b2bd5 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -5,6 +5,7 @@ import type {Country} from '@src/CONST'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, @@ -4602,6 +4603,7 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, + addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => diff --git a/src/languages/es.ts b/src/languages/es.ts index eb077bfcc1f7..05b1ce10638f 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4,6 +4,7 @@ import type en from './en'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, @@ -4649,6 +4650,7 @@ const translations = { addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `agregó la categoría "${categoryName}"`, deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, + addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, diff --git a/src/languages/params.ts b/src/languages/params.ts index 7bdb79a4ae00..be8bcd7ffe57 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -294,6 +294,8 @@ type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; +type AddedPolicyReportFieldParams = {fieldType: string; fieldName?: string}; + type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; type UpdatedPolicyFieldWithNewAndOldValueParams = {oldValue: string; newValue: string}; @@ -843,4 +845,5 @@ export type { TripLengthTextParams, EditDestinationSubtitleParams, FlightLayoverParams, + AddedPolicyReportFieldParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index cac5bfc3a553..7b97d12ba1ec 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1843,6 +1843,19 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { return getReportActionText(action); } +function getWorkspaceReportFieldAddMessage(action: ReportAction): string { + const {fieldName, fieldType} = getOriginalMessage(action as ReportAction) ?? {}; + + if (fieldName && fieldType) { + return Localize.translateLocal('workspaceActions.addedReportField', { + fieldName, + fieldType, + }); + } + + return getReportActionText(action); +} + function getWorkspaceUpdateFieldMessage(action: ReportAction): string { const {newValue, oldValue, updatedField} = getOriginalMessage(action as ReportAction) ?? {}; @@ -2178,6 +2191,7 @@ export { getPolicyChangeLogDefaultBillableMessage, getPolicyChangeLogDefaultTitleEnforcedMessage, getWorkspaceDescriptionUpdatedMessage, + getWorkspaceReportFieldAddMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 24a22bad988a..cadff63cce85 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -490,6 +490,8 @@ function getOptionData({ ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { + result.alternateText = ReportActionsUtils.getWorkspaceReportFieldAddMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index d6c982e0d166..309e17e1ed59 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -430,6 +430,8 @@ const ContextMenuActions: ContextMenuAction[] = [ reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { + Clipboard.setString(ReportActionsUtils.getWorkspaceReportFieldAddMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index f4c064606ab8..e1ed10e2c356 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -837,6 +837,8 @@ function PureReportActionItem({ action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { + children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 5bd0d5e310f6..848a423b45a7 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -368,6 +368,12 @@ type OriginalMessagePolicyChangeLog = { /** Old desciption */ oldDescription?: string; + + /** Report field type */ + fieldType?: string; + + /** Report field name */ + fieldName?: string; }; /** Model of `join policy changelog` report action */ From 1c13ce04c8c8cfe817770a8ca2fdf713e1cf4ddb Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 13 Jan 2025 00:20:04 +0530 Subject: [PATCH 18/38] add translations for ADD_CUSTOM_UNIT_RATE. Signed-off-by: krishna2323 --- src/languages/en.ts | 2 ++ src/languages/es.ts | 2 ++ src/languages/params.ts | 3 +++ src/libs/ReportActionsUtils.ts | 14 ++++++++++++++ src/libs/SidebarUtils.ts | 2 ++ .../home/report/ContextMenu/ContextMenuActions.tsx | 2 ++ src/pages/home/report/PureReportActionItem.tsx | 2 ++ src/types/onyx/OriginalMessage.ts | 6 ++++++ 8 files changed, 33 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index d209de0edf81..2d7c1fa3e80c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -5,6 +5,7 @@ import type {Country} from '@src/CONST'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedPolicyCustomUnitRateParams, AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, @@ -4606,6 +4607,7 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, + addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `added a new "${customUnitName}" rate "${rateName}"`, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, diff --git a/src/languages/es.ts b/src/languages/es.ts index 5abcae896771..1300d91cf113 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4,6 +4,7 @@ import type en from './en'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedPolicyCustomUnitRateParams, AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, @@ -4655,6 +4656,7 @@ const translations = { updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, + addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `agregó una nueva tasa de "${rateName}" para "${customUnitName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => diff --git a/src/languages/params.ts b/src/languages/params.ts index be8bcd7ffe57..a85360d0b4ce 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -294,6 +294,8 @@ type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; +type AddedPolicyCustomUnitRateParams = {customUnitName: string; rateName: string}; + type AddedPolicyReportFieldParams = {fieldType: string; fieldName?: string}; type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; @@ -846,4 +848,5 @@ export type { EditDestinationSubtitleParams, FlightLayoverParams, AddedPolicyReportFieldParams, + AddedPolicyCustomUnitRateParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 7b97d12ba1ec..e0aa8b74f5df 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1843,6 +1843,19 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { return getReportActionText(action); } +function getWorkspaceCustomUnitRateAddedMessage(action: ReportAction): string { + const {customUnitName, rateName} = getOriginalMessage(action as ReportAction) ?? {}; + + if (customUnitName && rateName) { + return Localize.translateLocal('workspaceActions.addCustomUnitRate', { + customUnitName, + rateName, + }); + } + + return getReportActionText(action); +} + function getWorkspaceReportFieldAddMessage(action: ReportAction): string { const {fieldName, fieldType} = getOriginalMessage(action as ReportAction) ?? {}; @@ -2192,6 +2205,7 @@ export { getPolicyChangeLogDefaultTitleEnforcedMessage, getWorkspaceDescriptionUpdatedMessage, getWorkspaceReportFieldAddMessage, + getWorkspaceCustomUnitRateAddedMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index cadff63cce85..3e6d37977db1 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -490,6 +490,8 @@ function getOptionData({ ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); + } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE)) { + result.alternateText = ReportActionsUtils.getWorkspaceCustomUnitRateAddedMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { result.alternateText = ReportActionsUtils.getWorkspaceReportFieldAddMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 309e17e1ed59..2296e529d887 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -430,6 +430,8 @@ const ContextMenuActions: ContextMenuAction[] = [ reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { + Clipboard.setString(ReportActionsUtils.getWorkspaceCustomUnitRateAddedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { Clipboard.setString(ReportActionsUtils.getWorkspaceReportFieldAddMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 97da03ef03cc..91dc2f3151af 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -837,6 +837,8 @@ function PureReportActionItem({ action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 848a423b45a7..c7b241f8e480 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -374,6 +374,12 @@ type OriginalMessagePolicyChangeLog = { /** Report field name */ fieldName?: string; + + /** Custom unit name */ + customUnitName?: string; + + /** Custom unit name */ + rateName?: string; }; /** Model of `join policy changelog` report action */ From dffaaddf20a6118815ab337d1fa70c444bf30a27 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 13 Jan 2025 00:51:03 +0530 Subject: [PATCH 19/38] add translations for ADD_TAG. Signed-off-by: krishna2323 --- src/languages/en.ts | 2 ++ src/languages/es.ts | 4 +++- src/languages/params.ts | 3 +++ src/libs/ReportActionsUtils.ts | 14 ++++++++++++++ src/libs/SidebarUtils.ts | 4 ++-- .../home/report/ContextMenu/ContextMenuActions.tsx | 3 +++ src/pages/home/report/PureReportActionItem.tsx | 4 ++-- src/types/onyx/OriginalMessage.ts | 6 ++++++ 8 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 2d7c1fa3e80c..65d82235f7d7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -181,6 +181,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyTagParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -4607,6 +4608,7 @@ const translations = { deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, + addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `added the tag "${tagName}" to the list "${tagListName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `added a new "${customUnitName}" rate "${rateName}"`, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => diff --git a/src/languages/es.ts b/src/languages/es.ts index 1300d91cf113..14c3a6223947 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -180,6 +180,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyTagParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -4654,8 +4655,9 @@ const translations = { addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `agregó la categoría "${categoryName}"`, deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, - addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, + addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `agregó la etiqueta "${tagName}" a la lista "${tagListName}"`, + addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `agregó una nueva tasa de "${rateName}" para "${customUnitName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, diff --git a/src/languages/params.ts b/src/languages/params.ts index a85360d0b4ce..44d544216ded 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -292,6 +292,8 @@ type UpdatedPolicyCurrencyParams = {oldCurrency: string; newCurrency: string}; type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; +type UpdatedPolicyTagParams = {tagListName: string; tagName: string}; + type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type AddedPolicyCustomUnitRateParams = {customUnitName: string; rateName: string}; @@ -849,4 +851,5 @@ export type { FlightLayoverParams, AddedPolicyReportFieldParams, AddedPolicyCustomUnitRateParams, + UpdatedPolicyTagParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index e0aa8b74f5df..f0b10d39302f 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1843,6 +1843,19 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { return getReportActionText(action); } +function getWorkspaceTagUpdateMessage(action: ReportAction): string { + const {tagListName, tagName} = getOriginalMessage(action as ReportAction) ?? {}; + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG && tagListName && tagName) { + return Localize.translateLocal('workspaceActions.addTag', { + tagListName, + tagName, + }); + } + + return getReportActionText(action); +} + function getWorkspaceCustomUnitRateAddedMessage(action: ReportAction): string { const {customUnitName, rateName} = getOriginalMessage(action as ReportAction) ?? {}; @@ -2206,6 +2219,7 @@ export { getWorkspaceDescriptionUpdatedMessage, getWorkspaceReportFieldAddMessage, getWorkspaceCustomUnitRateAddedMessage, + getWorkspaceTagUpdateMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 3e6d37977db1..894bb0e5e41f 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -490,6 +490,8 @@ function getOptionData({ ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); + } else if (ReportActionsUtils.isTagModificationAction(lastAction?.actionName)) { + result.alternateText = PolicyUtils.getCleanedTagName(ReportActionsUtils.getWorkspaceTagUpdateMessage(lastAction) ?? ''); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE)) { result.alternateText = ReportActionsUtils.getWorkspaceCustomUnitRateAddedMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { @@ -510,8 +512,6 @@ function getOptionData({ result.alternateText = ReportActionsUtils.getCardIssuedMessage(lastAction); } else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) { result.alternateText = ReportUtils.formatReportLastMessageText(Parser.htmlToText(`${lastActorDisplayName}: ${lastMessageText}`)); - } 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); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 2296e529d887..71c904a45949 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -20,6 +20,7 @@ import * as Localize from '@libs/Localize'; import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; import Navigation from '@libs/Navigation/Navigation'; import Parser from '@libs/Parser'; +import * as PolicyUtils from '@libs/PolicyUtils'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; @@ -430,6 +431,8 @@ const ContextMenuActions: ContextMenuAction[] = [ reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); + } else if (ReportActionsUtils.isTagModificationAction(reportAction.actionName)) { + Clipboard.setString(PolicyUtils.getCleanedTagName(ReportActionsUtils.getWorkspaceTagUpdateMessage(reportAction))); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { Clipboard.setString(ReportActionsUtils.getWorkspaceCustomUnitRateAddedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 91dc2f3151af..874edbe9ef45 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -816,8 +816,6 @@ function PureReportActionItem({ children = ; } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { children = ; - } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { - children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION) { @@ -837,6 +835,8 @@ function PureReportActionItem({ action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { children = ; + } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index c7b241f8e480..079650c7f5d8 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -380,6 +380,12 @@ type OriginalMessagePolicyChangeLog = { /** Custom unit name */ rateName?: string; + + /** Added/Updated tag name */ + tagName?: string; + + /** Updated tag list name */ + tagListName?: string; }; /** Model of `join policy changelog` report action */ From fce003ea93435bad6d8e6b50ec335aacfb8270f4 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 13 Jan 2025 01:12:29 +0530 Subject: [PATCH 20/38] add translations for DELETE_TAG & UPDATE_TAG_ENABLED. Signed-off-by: krishna2323 --- src/languages/en.ts | 2 ++ src/languages/es.ts | 2 ++ src/languages/params.ts | 2 +- src/libs/ReportActionsUtils.ts | 16 +++++++++++++++- src/types/onyx/OriginalMessage.ts | 3 +++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 65d82235f7d7..43479ad2719f 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4609,6 +4609,8 @@ const translations = { updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `added the tag "${tagName}" to the list "${tagListName}"`, + deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `removed the tag "${tagName}" from the list "${tagListName}"`, + updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'enabled' : 'disabled'} the tag "${tagName}" on the list "${tagListName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `added a new "${customUnitName}" rate "${rateName}"`, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => diff --git a/src/languages/es.ts b/src/languages/es.ts index 14c3a6223947..67303dd57ec2 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4657,6 +4657,8 @@ const translations = { updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `agregó la etiqueta "${tagName}" a la lista "${tagListName}"`, + deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `eliminó la etiqueta "${tagName}" de la lista "${tagListName}"`, + updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'habilitó' : 'deshabilitó'} la etiqueta "${tagName}" en la lista "${tagListName}"`, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `agregó una nueva tasa de "${rateName}" para "${customUnitName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => diff --git a/src/languages/params.ts b/src/languages/params.ts index 44d544216ded..ef3cbf2c0211 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -292,7 +292,7 @@ type UpdatedPolicyCurrencyParams = {oldCurrency: string; newCurrency: string}; type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; -type UpdatedPolicyTagParams = {tagListName: string; tagName: string}; +type UpdatedPolicyTagParams = {tagListName: string; tagName: string; enabled?: boolean}; type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index f0b10d39302f..2e5fa46939b0 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1844,7 +1844,7 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { } function getWorkspaceTagUpdateMessage(action: ReportAction): string { - const {tagListName, tagName} = getOriginalMessage(action as ReportAction) ?? {}; + const {tagListName, tagName, enabled} = getOriginalMessage(action as ReportAction) ?? {}; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG && tagListName && tagName) { return Localize.translateLocal('workspaceActions.addTag', { @@ -1853,6 +1853,20 @@ function getWorkspaceTagUpdateMessage(action: ReportAction): string { }); } + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAG && tagListName && tagName) { + return Localize.translateLocal('workspaceActions.deleteTag', { + tagListName, + tagName, + }); + } + + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_ENABLED && tagListName && tagName) { + return Localize.translateLocal('workspaceActions.updateTagEnabled', { + tagListName, + tagName, + }); + } + return getReportActionText(action); } diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 079650c7f5d8..286debb4633b 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -386,6 +386,9 @@ type OriginalMessagePolicyChangeLog = { /** Updated tag list name */ tagListName?: string; + + /** Updated tag enabled/disabled value */ + enabled?: boolean; }; /** Model of `join policy changelog` report action */ From 72f5408f0da0eb194f7d910d6a5d203987621096 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 13 Jan 2025 01:13:54 +0530 Subject: [PATCH 21/38] minor fix. Signed-off-by: krishna2323 --- src/libs/ReportActionsUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 2e5fa46939b0..a1241ea953f1 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1864,6 +1864,7 @@ function getWorkspaceTagUpdateMessage(action: ReportAction): string { return Localize.translateLocal('workspaceActions.updateTagEnabled', { tagListName, tagName, + enabled, }); } From d25a3d4cb78da16fb53eac5baf3fcaac9fe8383f Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 13 Jan 2025 01:23:49 +0530 Subject: [PATCH 22/38] add translations for UPDATE_TAG_NAME. Signed-off-by: krishna2323 --- src/languages/en.ts | 2 ++ src/languages/es.ts | 2 ++ src/languages/params.ts | 3 +++ src/libs/ReportActionsUtils.ts | 10 +++++++++- src/types/onyx/OriginalMessage.ts | 4 ++-- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 43479ad2719f..ccc571a5eee4 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -181,6 +181,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, @@ -4611,6 +4612,7 @@ const translations = { addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `added the tag "${tagName}" to the list "${tagListName}"`, deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `removed the tag "${tagName}" from the list "${tagListName}"`, updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'enabled' : 'disabled'} the tag "${tagName}" on the list "${tagListName}"`, + updateTagName: ({tagListName, newName, oldName}: UpdatedPolicyTagNameParams) => `updated the tag list "${tagListName}" by changing the tag "${oldName}" to be "${newName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `added a new "${customUnitName}" rate "${rateName}"`, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => diff --git a/src/languages/es.ts b/src/languages/es.ts index 67303dd57ec2..653461eab7b7 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -180,6 +180,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, @@ -4659,6 +4660,7 @@ const translations = { addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `agregó la etiqueta "${tagName}" a la lista "${tagListName}"`, deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `eliminó la etiqueta "${tagName}" de la lista "${tagListName}"`, updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'habilitó' : 'deshabilitó'} la etiqueta "${tagName}" en la lista "${tagListName}"`, + updateTagName: ({tagListName, newName, oldName}: UpdatedPolicyTagNameParams) => `actualizó la lista de etiquetas "${tagListName}" cambiando la etiqueta "${oldName}" a "${newName}"`, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `agregó una nueva tasa de "${rateName}" para "${customUnitName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => diff --git a/src/languages/params.ts b/src/languages/params.ts index ef3cbf2c0211..50b9dc1d750f 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -294,6 +294,8 @@ type UpdatedPolicyCategoryParams = {categoryName: string; oldValue?: boolean}; type UpdatedPolicyTagParams = {tagListName: string; tagName: string; enabled?: boolean}; +type UpdatedPolicyTagNameParams = {oldName: string; newName: string; tagListName: string}; + type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type AddedPolicyCustomUnitRateParams = {customUnitName: string; rateName: string}; @@ -852,4 +854,5 @@ export type { AddedPolicyReportFieldParams, AddedPolicyCustomUnitRateParams, UpdatedPolicyTagParams, + UpdatedPolicyTagNameParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index a1241ea953f1..d91000629e1a 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1844,7 +1844,7 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { } function getWorkspaceTagUpdateMessage(action: ReportAction): string { - const {tagListName, tagName, enabled} = getOriginalMessage(action as ReportAction) ?? {}; + const {tagListName, tagName, enabled, newName, oldName} = getOriginalMessage(action as ReportAction) ?? {}; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG && tagListName && tagName) { return Localize.translateLocal('workspaceActions.addTag', { @@ -1868,6 +1868,14 @@ function getWorkspaceTagUpdateMessage(action: ReportAction): string { }); } + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_NAME && tagListName && newName && oldName) { + return Localize.translateLocal('workspaceActions.updateTagName', { + tagListName, + newName, + oldName, + }); + } + return getReportActionText(action); } diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 286debb4633b..23c9b349b5d1 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -297,10 +297,10 @@ type OriginalMessagePolicyChangeLog = { /** ID of the report */ reportID?: number; - /** Old name of the workspace */ + /** Old name of the workspace/tag */ oldName?: string; - /** New name of the workspace */ + /** New name of the workspace/tag */ newName?: string; /** Email of user */ From be8b783f4bd8927025be3da6b6d67435ae9531bf Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 13 Jan 2025 02:44:11 +0530 Subject: [PATCH 23/38] add translations for UPDATE_TAG. Signed-off-by: krishna2323 --- src/languages/en.ts | 11 +++++++++-- src/languages/es.ts | 11 +++++++++-- src/languages/params.ts | 3 +++ src/libs/ReportActionsUtils.ts | 20 +++++++++++++++++++- src/types/onyx/OriginalMessage.ts | 4 ++-- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index ccc571a5eee4..d9fd73568601 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -181,6 +181,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyTagFieldParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, UpdatedTheDistanceMerchantParams, @@ -4610,9 +4611,15 @@ const translations = { updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `added the tag "${tagName}" to the list "${tagListName}"`, - deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `removed the tag "${tagName}" from the list "${tagListName}"`, - updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'enabled' : 'disabled'} the tag "${tagName}" on the list "${tagListName}"`, updateTagName: ({tagListName, newName, oldName}: UpdatedPolicyTagNameParams) => `updated the tag list "${tagListName}" by changing the tag "${oldName}" to be "${newName}"`, + updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'enabled' : 'disabled'} the tag "${tagName}" on the list "${tagListName}"`, + deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `removed the tag "${tagName}" from the list "${tagListName}"`, + updateTag: ({tagListName, newValue, tagName, updatedField, oldValue}: UpdatedPolicyTagFieldParams) => { + if (oldValue) { + return `updated the tag "${tagName}" on the list "${tagListName}" by changing the ${updatedField} from "${oldValue}" to "${newValue}"`; + } + return `updated the tag "${tagName}" on the list "${tagListName}" by adding a ${updatedField} of "${newValue}"`; + }, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `added a new "${customUnitName}" rate "${rateName}"`, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => diff --git a/src/languages/es.ts b/src/languages/es.ts index 653461eab7b7..79ad6e30bff8 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -180,6 +180,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyTagFieldParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, UpdatedTheDistanceMerchantParams, @@ -4658,9 +4659,15 @@ const translations = { updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `agregó la etiqueta "${tagName}" a la lista "${tagListName}"`, - deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `eliminó la etiqueta "${tagName}" de la lista "${tagListName}"`, - updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'habilitó' : 'deshabilitó'} la etiqueta "${tagName}" en la lista "${tagListName}"`, updateTagName: ({tagListName, newName, oldName}: UpdatedPolicyTagNameParams) => `actualizó la lista de etiquetas "${tagListName}" cambiando la etiqueta "${oldName}" a "${newName}"`, + updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'habilitó' : 'deshabilitó'} la etiqueta "${tagName}" en la lista "${tagListName}"`, + deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `eliminó la etiqueta "${tagName}" de la lista "${tagListName}"`, + updateTag: ({tagListName, newValue, tagName, updatedField, oldValue}: UpdatedPolicyTagFieldParams) => { + if (oldValue) { + return `actualizó la etiqueta "${tagName}" en la lista "${tagListName}" cambiando el ${updatedField} de "${oldValue}" a "${newValue}"`; + } + return `actualizó la etiqueta "${tagName}" en la lista "${tagListName}" añadiendo un ${updatedField} de "${newValue}"`; + }, addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `agregó una nueva tasa de "${rateName}" para "${customUnitName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => diff --git a/src/languages/params.ts b/src/languages/params.ts index 50b9dc1d750f..86e6ceb9adc4 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -296,6 +296,8 @@ type UpdatedPolicyTagParams = {tagListName: string; tagName: string; enabled?: b type UpdatedPolicyTagNameParams = {oldName: string; newName: string; tagListName: string}; +type UpdatedPolicyTagFieldParams = {oldValue?: string; newValue: string; tagName: string; tagListName: string; updatedField: string}; + type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type AddedPolicyCustomUnitRateParams = {customUnitName: string; rateName: string}; @@ -855,4 +857,5 @@ export type { AddedPolicyCustomUnitRateParams, UpdatedPolicyTagParams, UpdatedPolicyTagNameParams, + UpdatedPolicyTagFieldParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index d91000629e1a..5b515132d181 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1844,7 +1844,8 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { } function getWorkspaceTagUpdateMessage(action: ReportAction): string { - const {tagListName, tagName, enabled, newName, oldName} = getOriginalMessage(action as ReportAction) ?? {}; + const {tagListName, tagName, enabled, newName, newValue, oldName, oldValue, updatedField} = + getOriginalMessage(action as ReportAction) ?? {}; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG && tagListName && tagName) { return Localize.translateLocal('workspaceActions.addTag', { @@ -1876,6 +1877,23 @@ function getWorkspaceTagUpdateMessage(action: ReportAction): string { }); } + if ( + action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG && + tagListName && + typeof oldValue === 'string' && + typeof newValue === 'string' && + tagName && + updatedField + ) { + return Localize.translateLocal('workspaceActions.updateTag', { + tagListName, + oldValue, + newValue, + tagName, + updatedField, + }); + } + return getReportActionText(action); } diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 23c9b349b5d1..9fb1b5feecfc 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -312,10 +312,10 @@ type OriginalMessagePolicyChangeLog = { /** When was it last modified */ lastModified?: string; - /** New Value */ + /** New Value of the category/tag field */ newValue?: boolean | string; - /** Old Value */ + /** Old Value of the category/tag field */ oldValue?: boolean | string; /** Old currency of the workspace */ From edebc15ebc056902ee0a6ffb74195abff8aa2015 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 21 Jan 2025 02:49:59 +0530 Subject: [PATCH 24/38] fix lint issues. Signed-off-by: krishna2323 --- src/languages/params.ts | 3 - src/libs/ReportActionsUtils.ts | 74 +++++++++---------- src/libs/SidebarUtils.ts | 4 +- .../report/ContextMenu/ContextMenuActions.tsx | 47 +++++++----- 4 files changed, 66 insertions(+), 62 deletions(-) diff --git a/src/languages/params.ts b/src/languages/params.ts index b60cd147a8bb..6723b8b7a882 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -836,9 +836,6 @@ export type { UpdatedPolicyFieldWithNewAndOldValueParams, UpdatedPolicyFieldWithValueParam, UpdatedPolicyDescriptionParams, - FirstDayTextParams, - LastDayTextParams, - TripLengthTextParams, EditDestinationSubtitleParams, FlightLayoverParams, AddedPolicyReportFieldParams, diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 4c19ffc77037..ea534a78ec00 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -16,7 +16,7 @@ import type ReportAction from '@src/types/onyx/ReportAction'; import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction'; import type ReportActionName from '@src/types/onyx/ReportActionName'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import * as CurrencyUtils from './CurrencyUtils'; +import {convertToDisplayString} from './CurrencyUtils'; import DateUtils from './DateUtils'; import {getEnvironmentURL} from './Environment/Environment'; import getBase62ReportID from './getBase62ReportID'; @@ -1747,8 +1747,8 @@ function getPolicyChangeLogChangeRoleMessage(reportAction: OnyxInputOrEntry) ?? {}; - const message = oldName && newName ? Localize.translateLocal('workspaceActions.renamedWorkspaceNameAction', {oldName, newName}) : getReportActionText(action); + const message = oldName && newName ? translateLocal('workspaceActions.renamedWorkspaceNameAction', {oldName, newName}) : getReportActionText(action); return message; } function getWorkspaceDescriptionUpdatedMessage(action: ReportAction) { const {oldDescription, newDescription} = getOriginalMessage(action as ReportAction) ?? {}; const message = - typeof oldDescription === 'string' && newDescription - ? Localize.translateLocal('workspaceActions.updateWorkspaceDescription', {newDescription, oldDescription}) - : getReportActionText(action); + typeof oldDescription === 'string' && newDescription ? translateLocal('workspaceActions.updateWorkspaceDescription', {newDescription, oldDescription}) : getReportActionText(action); return message; } function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { const {oldCurrency, newCurrency} = getOriginalMessage(action as ReportAction) ?? {}; - const message = oldCurrency && newCurrency ? Localize.translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : getReportActionText(action); + const message = oldCurrency && newCurrency ? translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : getReportActionText(action); return message; } @@ -1783,13 +1781,13 @@ type AutoReportingFrequencyKey = ValueOf; const getAutoReportingFrequencyDisplayNames = (): AutoReportingFrequencyDisplayNames => ({ - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.monthly'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: Localize.translateLocal('workflowsPage.frequencies.daily'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: Localize.translateLocal('workflowsPage.frequencies.weekly'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: Localize.translateLocal('workflowsPage.frequencies.twiceAMonth'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: Localize.translateLocal('workflowsPage.frequencies.byTrip'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: Localize.translateLocal('workflowsPage.frequencies.manually'), - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: Localize.translateLocal('workflowsPage.frequencies.instant'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: translateLocal('workflowsPage.frequencies.monthly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: translateLocal('workflowsPage.frequencies.daily'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: translateLocal('workflowsPage.frequencies.weekly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: translateLocal('workflowsPage.frequencies.twiceAMonth'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: translateLocal('workflowsPage.frequencies.byTrip'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: translateLocal('workflowsPage.frequencies.manually'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: translateLocal('workflowsPage.frequencies.instant'), }); function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { @@ -1807,7 +1805,7 @@ function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { return getReportActionText(action); } - return Localize.translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { + return translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { oldFrequency: oldFrequencyTranslation, newFrequency: newFrequencyTranslation, }); @@ -1817,26 +1815,26 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction): string { const {categoryName, oldValue, newName, oldName} = getOriginalMessage(action as ReportAction) ?? {}; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.addCategory', { + return translateLocal('workspaceActions.addCategory', { categoryName, }); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.deleteCategory', { + return translateLocal('workspaceActions.deleteCategory', { categoryName, }); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY && categoryName) { - return Localize.translateLocal('workspaceActions.updateCategory', { + return translateLocal('workspaceActions.updateCategory', { oldValue: !!oldValue, categoryName, }); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME && oldName && newName) { - return Localize.translateLocal('workspaceActions.setCategoryName', { + return translateLocal('workspaceActions.setCategoryName', { oldName, newName, }); @@ -1850,21 +1848,21 @@ function getWorkspaceTagUpdateMessage(action: ReportAction): string { getOriginalMessage(action as ReportAction) ?? {}; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG && tagListName && tagName) { - return Localize.translateLocal('workspaceActions.addTag', { + return translateLocal('workspaceActions.addTag', { tagListName, tagName, }); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAG && tagListName && tagName) { - return Localize.translateLocal('workspaceActions.deleteTag', { + return translateLocal('workspaceActions.deleteTag', { tagListName, tagName, }); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_ENABLED && tagListName && tagName) { - return Localize.translateLocal('workspaceActions.updateTagEnabled', { + return translateLocal('workspaceActions.updateTagEnabled', { tagListName, tagName, enabled, @@ -1872,7 +1870,7 @@ function getWorkspaceTagUpdateMessage(action: ReportAction): string { } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_NAME && tagListName && newName && oldName) { - return Localize.translateLocal('workspaceActions.updateTagName', { + return translateLocal('workspaceActions.updateTagName', { tagListName, newName, oldName, @@ -1887,7 +1885,7 @@ function getWorkspaceTagUpdateMessage(action: ReportAction): string { tagName && updatedField ) { - return Localize.translateLocal('workspaceActions.updateTag', { + return translateLocal('workspaceActions.updateTag', { tagListName, oldValue, newValue, @@ -1903,7 +1901,7 @@ function getWorkspaceCustomUnitRateAddedMessage(action: ReportAction): string { const {customUnitName, rateName} = getOriginalMessage(action as ReportAction) ?? {}; if (customUnitName && rateName) { - return Localize.translateLocal('workspaceActions.addCustomUnitRate', { + return translateLocal('workspaceActions.addCustomUnitRate', { customUnitName, rateName, }); @@ -1916,7 +1914,7 @@ function getWorkspaceReportFieldAddMessage(action: ReportAction): string { const {fieldName, fieldType} = getOriginalMessage(action as ReportAction) ?? {}; if (fieldName && fieldType) { - return Localize.translateLocal('workspaceActions.addedReportField', { + return translateLocal('workspaceActions.addedReportField', { fieldName, fieldType, }); @@ -1934,7 +1932,7 @@ function getWorkspaceUpdateFieldMessage(action: ReportAction): string { CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] && CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] ) { - return Localize.translateLocal('workspaceActions.updateApprovalMode', { + return translateLocal('workspaceActions.updateApprovalMode', { oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], fieldName: updatedField, @@ -1942,14 +1940,14 @@ function getWorkspaceUpdateFieldMessage(action: ReportAction): string { } if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.PREVENT_SELF_APPROVAL && typeof oldValue === 'string' && typeof newValue === 'string') { - return Localize.translateLocal('workspaceActions.preventSelfApproval', { + return translateLocal('workspaceActions.preventSelfApproval', { oldValue, newValue, }); } if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.MAX_EXPENSE_AGE && typeof oldValue === 'string' && typeof newValue === 'string') { - return Localize.translateLocal('workspaceActions.updateMaxExpenseAge', { + return translateLocal('workspaceActions.updateMaxExpenseAge', { oldValue, newValue, }); @@ -1963,9 +1961,9 @@ function getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(action: ReportActio getOriginalMessage(action as ReportAction) ?? {}; if (typeof oldMaxExpenseAmountNoReceipt === 'number' && typeof newMaxExpenseAmountNoReceipt === 'number') { - return Localize.translateLocal('workspaceActions.updateMaxExpenseAmountNoReceipt', { - oldValue: CurrencyUtils.convertToDisplayString(oldMaxExpenseAmountNoReceipt, currency), - newValue: CurrencyUtils.convertToDisplayString(newMaxExpenseAmountNoReceipt, currency), + return translateLocal('workspaceActions.updateMaxExpenseAmountNoReceipt', { + oldValue: convertToDisplayString(oldMaxExpenseAmountNoReceipt, currency), + newValue: convertToDisplayString(newMaxExpenseAmountNoReceipt, currency), }); } @@ -1977,9 +1975,9 @@ function getPolicyChangeLogMaxExpenseAmountMessage(action: ReportAction): string getOriginalMessage(action as ReportAction) ?? {}; if (typeof oldMaxExpenseAmount === 'number' && typeof newMaxExpenseAmount === 'number') { - return Localize.translateLocal('workspaceActions.updateMaxExpenseAmount', { - oldValue: CurrencyUtils.convertToDisplayString(oldMaxExpenseAmount, currency), - newValue: CurrencyUtils.convertToDisplayString(newMaxExpenseAmount, currency), + return translateLocal('workspaceActions.updateMaxExpenseAmount', { + oldValue: convertToDisplayString(oldMaxExpenseAmount, currency), + newValue: convertToDisplayString(newMaxExpenseAmount, currency), }); } @@ -1990,7 +1988,7 @@ function getPolicyChangeLogDefaultBillableMessage(action: ReportAction): string const {oldDefaultBillable, newDefaultBillable} = getOriginalMessage(action as ReportAction) ?? {}; if (typeof oldDefaultBillable === 'string' && typeof newDefaultBillable === 'string') { - return Localize.translateLocal('workspaceActions.updateDefaultBillable', { + return translateLocal('workspaceActions.updateDefaultBillable', { oldValue: oldDefaultBillable, newValue: newDefaultBillable, }); @@ -2003,7 +2001,7 @@ function getPolicyChangeLogDefaultTitleEnforcedMessage(action: ReportAction): st const {value} = getOriginalMessage(action as ReportAction) ?? {}; if (typeof value === 'boolean') { - return Localize.translateLocal('workspaceActions.updateDefaultTitleEnforced', { + return translateLocal('workspaceActions.updateDefaultTitleEnforced', { value, }); } diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index c5b37ced6965..bc56b9401702 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -481,9 +481,9 @@ function getOptionData({ } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { result.alternateText = ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(lastAction); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { - result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan'); + result.alternateText = Localize.translateLocal('workspaceActions.upgradedWorkspace'); } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE)) { - result.alternateText = Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlanDowngrade'); + result.alternateText = Localize.translateLocal('workspaceActions.downgradedWorkspace'); } else if ( ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index c04f82e77e94..057b5d72e5a4 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -32,11 +32,23 @@ import { getOriginalMessage, getPolicyChangeLogAddEmployeeMessage, getPolicyChangeLogChangeRoleMessage, + getPolicyChangeLogDefaultBillableMessage, + getPolicyChangeLogDefaultTitleEnforcedMessage, getPolicyChangeLogDeleteMemberMessage, + getPolicyChangeLogMaxExpenseAmountMessage, + getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, getRemovedConnectionMessage, getRenamedAction, getReportActionMessageText, getUpdateRoomDescriptionMessage, + getWorkspaceCategoryUpdateMessage, + getWorkspaceCurrencyUpdateMessage, + getWorkspaceCustomUnitRateAddedMessage, + getWorkspaceDescriptionUpdatedMessage, + getWorkspaceFrequencyUpdateMessage, + getWorkspaceReportFieldAddMessage, + getWorkspaceTagUpdateMessage, + getWorkspaceUpdateFieldMessage, isActionableMentionWhisper, isActionableTrackExpense, isActionOfType, @@ -53,6 +65,7 @@ import { isRenamedAction, isReportActionAttachment, isReportPreviewAction as isReportPreviewActionReportActionsUtils, + isTagModificationAction, isTaskAction as isTaskActionReportActionsUtils, isTripPreview, isUnapprovedAction, @@ -484,41 +497,37 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { Clipboard.setString(Str.htmlDecode(getWorkspaceNameUpdatedMessage(reportAction))); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION) { - Clipboard.setString(ReportActionsUtils.getWorkspaceDescriptionUpdatedMessage(reportAction)); + Clipboard.setString(getWorkspaceDescriptionUpdatedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - Clipboard.setString(ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(reportAction)); + Clipboard.setString(getWorkspaceCurrencyUpdateMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - Clipboard.setString(ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(reportAction)); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { - Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlan')); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { - Clipboard.setString(Localize.translateLocal('workspaceActions.updatedWorkspaceCorporatePlanDowngrade')); + Clipboard.setString(getWorkspaceFrequencyUpdateMessage(reportAction)); } else if ( reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { - Clipboard.setString(ReportActionsUtils.getWorkspaceCategoryUpdateMessage(reportAction)); - } else if (ReportActionsUtils.isTagModificationAction(reportAction.actionName)) { - Clipboard.setString(PolicyUtils.getCleanedTagName(ReportActionsUtils.getWorkspaceTagUpdateMessage(reportAction))); + Clipboard.setString(getWorkspaceCategoryUpdateMessage(reportAction)); + } else if (isTagModificationAction(reportAction.actionName)) { + Clipboard.setString(PolicyUtils.getCleanedTagName(getWorkspaceTagUpdateMessage(reportAction))); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { - Clipboard.setString(ReportActionsUtils.getWorkspaceCustomUnitRateAddedMessage(reportAction)); + Clipboard.setString(getWorkspaceCustomUnitRateAddedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { - Clipboard.setString(ReportActionsUtils.getWorkspaceReportFieldAddMessage(reportAction)); + Clipboard.setString(getWorkspaceReportFieldAddMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - setClipboardMessage(ReportActionsUtils.getWorkspaceUpdateFieldMessage(reportAction)); + setClipboardMessage(getWorkspaceUpdateFieldMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { - Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(reportAction)); + Clipboard.setString(getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { - Clipboard.setString(ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(reportAction)); + Clipboard.setString(getPolicyChangeLogMaxExpenseAmountMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE) { - Clipboard.setString(ReportActionsUtils.getPolicyChangeLogDefaultBillableMessage(reportAction)); + Clipboard.setString(getPolicyChangeLogDefaultBillableMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED) { - Clipboard.setString(ReportActionsUtils.getPolicyChangeLogDefaultTitleEnforcedMessage(reportAction)); - } else if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { + Clipboard.setString(getPolicyChangeLogDefaultTitleEnforcedMessage(reportAction)); + } else if (isReimbursementQueuedAction(reportAction)) { Clipboard.setString(getReimbursementQueuedActionMessage(reportAction, reportID, false)); - } else if (ReportActionsUtils.isActionableMentionWhisper(reportAction)) { + } else if (isActionableMentionWhisper(reportAction)) { const mentionWhisperMessage = getActionableMentionWhisperMessage(reportAction); setClipboardMessage(mentionWhisperMessage); } else if (isActionableTrackExpense(reportAction)) { From 7b54ec190b9c898bfa15b849a3dc74dd2c339396 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 21 Jan 2025 03:00:55 +0530 Subject: [PATCH 25/38] fix lint issues. Signed-off-by: krishna2323 --- src/libs/SidebarUtils.ts | 219 ++++++++++-------- .../report/ContextMenu/ContextMenuActions.tsx | 4 +- .../home/report/PureReportActionItem.tsx | 4 - 3 files changed, 127 insertions(+), 100 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index bc56b9401702..ce22f60d7454 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -12,16 +12,51 @@ import type PriorityMode from '@src/types/onyx/PriorityMode'; import type Report from '@src/types/onyx/Report'; import type ReportAction from '@src/types/onyx/ReportAction'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; -import * as CollectionUtils from './CollectionUtils'; +import {extractCollectionItemID} from './CollectionUtils'; import {hasValidDraftComment} from './DraftCommentUtils'; import localeCompare from './LocaleCompare'; -import * as LocalePhoneNumber from './LocalePhoneNumber'; -import * as Localize from './Localize'; -import * as OptionsListUtils from './OptionsListUtils'; +import {formatPhoneNumber} from './LocalePhoneNumber'; +import {translate, translateLocal} from './Localize'; +import {getLastActorDisplayName, getLastMessageTextForReport, getPersonalDetailsForAccountIDs} from './OptionsListUtils'; import Parser from './Parser'; import Performance from './Performance'; -import * as PolicyUtils from './PolicyUtils'; -import * as ReportActionsUtils from './ReportActionsUtils'; +import {getCleanedTagName, getPolicy} from './PolicyUtils'; +import { + getCardIssuedMessage, + getLastVisibleMessage, + getMessageOfOldDotReportAction, + getOriginalMessage, + getPolicyChangeLogAddEmployeeMessage, + getPolicyChangeLogChangeRoleMessage, + getPolicyChangeLogDefaultBillableMessage, + getPolicyChangeLogDefaultTitleEnforcedMessage, + getPolicyChangeLogDeleteMemberMessage, + getPolicyChangeLogMaxExpenseAmountMessage, + getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, + getRemovedConnectionMessage, + getRenamedAction, + getReportAction, + getReportActionMessageText, + getSortedReportActions, + getUpdateRoomDescriptionMessage, + getWorkspaceCategoryUpdateMessage, + getWorkspaceCurrencyUpdateMessage, + getWorkspaceCustomUnitRateAddedMessage, + getWorkspaceDescriptionUpdatedMessage, + getWorkspaceFrequencyUpdateMessage, + getWorkspaceNameUpdatedMessage, + getWorkspaceReportFieldAddMessage, + getWorkspaceTagUpdateMessage, + getWorkspaceUpdateFieldMessage, + isActionOfType, + isCardIssuedAction, + isInviteOrRemovedAction, + isOldDotReportAction, + isRenamedAction, + isTagModificationAction, + isTaskAction, + shouldReportActionBeVisibleAsLastAction, +} from './ReportActionsUtils'; import * as ReportUtils from './ReportUtils'; import * as TaskUtils from './TaskUtils'; @@ -51,16 +86,15 @@ Onyx.connect({ if (!actions || !key) { return; } - const reportID = CollectionUtils.extractCollectionItemID(key); + const reportID = extractCollectionItemID(key); const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report); - const actionsArray: ReportAction[] = ReportActionsUtils.getSortedReportActions(Object.values(actions)); + const actionsArray: ReportAction[] = getSortedReportActions(Object.values(actions)); // The report is only visible if it is the last action not deleted that // does not match a closed or created state. const reportActionsForDisplay = actionsArray.filter( - (reportAction) => - ReportActionsUtils.shouldReportActionBeVisibleAsLastAction(reportAction, canUserPerformWriteAction) && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED, + (reportAction) => shouldReportActionBeVisibleAsLastAction(reportAction, canUserPerformWriteAction) && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED, ); const reportAction = reportActionsForDisplay.at(-1); @@ -123,7 +157,7 @@ function getOrderedReportIDs( if ((Object.values(CONST.REPORT.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) { return; } - const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID, report?.parentReportActionID); + const parentReportAction = getReportAction(report?.parentReportID, report?.parentReportActionID); const doesReportHaveViolations = ReportUtils.shouldDisplayViolationsRBRInLHN(report, transactionViolations); const isHidden = ReportUtils.isHiddenForCurrentUser(report); const isFocused = report.reportID === currentReportId; @@ -200,7 +234,7 @@ function getOrderedReportIDs( }; const isPinned = report?.isPinned ?? false; - const reportAction = ReportActionsUtils.getReportAction(report?.parentReportID, report?.parentReportActionID); + const reportAction = getReportAction(report?.parentReportID, report?.parentReportActionID); const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) { pinnedAndGBRReports.push(miniReport); @@ -356,7 +390,7 @@ function getOptionData({ const participantAccountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(report); const visibleParticipantAccountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(report, true); - const participantPersonalDetailList = Object.values(OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)); + const participantPersonalDetailList = Object.values(getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)); const personalDetail = participantPersonalDetailList.at(0) ?? ({} as PersonalDetails); result.isThread = ReportUtils.isChatThread(report); @@ -404,7 +438,7 @@ function getOptionData({ const login = Str.removeSMSDomain(personalDetail?.login ?? ''); const status = personalDetail?.status ?? ''; - const formattedLogin = Str.isSMSLogin(login) ? LocalePhoneNumber.formatPhoneNumber(login) : login; + const formattedLogin = Str.isSMSLogin(login) ? formatPhoneNumber(login) : login; // We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade. const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips( @@ -429,11 +463,11 @@ function getOptionData({ : null; } - const lastActorDisplayName = OptionsListUtils.getLastActorDisplayName(lastActorDetails, hasMultipleParticipants); + const lastActorDisplayName = getLastActorDisplayName(lastActorDetails, hasMultipleParticipants); let lastMessageTextFromReport = lastMessageTextFromReportProp; if (!lastMessageTextFromReport) { - lastMessageTextFromReport = OptionsListUtils.getLastMessageTextForReport(report, lastActorDetails, policy); + lastMessageTextFromReport = getLastMessageTextForReport(report, lastActorDetails, policy); } // We need to remove sms domain in case the last message text has a phone number mention with sms domain. @@ -447,96 +481,96 @@ function getOptionData({ if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage || isGroupChat) && !result.private_isArchived) { const lastActionName = lastAction?.actionName ?? report.lastActionType; - if (ReportActionsUtils.isRenamedAction(lastAction)) { - result.alternateText = ReportActionsUtils.getRenamedAction(lastAction); - } else if (ReportActionsUtils.isTaskAction(lastAction)) { + if (isRenamedAction(lastAction)) { + result.alternateText = getRenamedAction(lastAction); + } else if (isTaskAction(lastAction)) { result.alternateText = ReportUtils.formatReportLastMessageText(TaskUtils.getTaskReportActionMessage(lastAction).text); - } else if (ReportActionsUtils.isInviteOrRemovedAction(lastAction)) { - const lastActionOriginalMessage = lastAction?.actionName ? ReportActionsUtils.getOriginalMessage(lastAction) : null; + } else if (isInviteOrRemovedAction(lastAction)) { + const lastActionOriginalMessage = lastAction?.actionName ? getOriginalMessage(lastAction) : null; const targetAccountIDs = lastActionOriginalMessage?.targetAccountIDs ?? []; const targetAccountIDsLength = targetAccountIDs.length !== 0 ? targetAccountIDs.length : report.lastMessageHtml?.match(/]*><\/mention-user>/g)?.length ?? 0; const verb = lastActionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM - ? Localize.translate(preferredLocale, 'workspace.invite.invited') - : Localize.translate(preferredLocale, 'workspace.invite.removed'); - const users = Localize.translate(preferredLocale, targetAccountIDsLength > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); + ? translate(preferredLocale, 'workspace.invite.invited') + : translate(preferredLocale, 'workspace.invite.removed'); + const users = translate(preferredLocale, targetAccountIDsLength > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); result.alternateText = ReportUtils.formatReportLastMessageText(`${lastActorDisplayName} ${verb} ${targetAccountIDsLength} ${users}`); const roomName = lastActionOriginalMessage?.roomName ?? ''; if (roomName) { const preposition = lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM - ? ` ${Localize.translate(preferredLocale, 'workspace.invite.to')}` - : ` ${Localize.translate(preferredLocale, 'workspace.invite.from')}`; + ? ` ${translate(preferredLocale, 'workspace.invite.to')}` + : ` ${translate(preferredLocale, 'workspace.invite.from')}`; result.alternateText += `${preposition} ${roomName}`; } - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) { - result.alternateText = `${lastActorDisplayName} ${ReportActionsUtils.getUpdateRoomDescriptionMessage(lastAction)}`; - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { - result.alternateText = ReportActionsUtils.getWorkspaceNameUpdatedMessage(lastAction); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION)) { - result.alternateText = ReportActionsUtils.getWorkspaceDescriptionUpdatedMessage(lastAction); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { - result.alternateText = ReportActionsUtils.getWorkspaceCurrencyUpdateMessage(lastAction); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { - result.alternateText = ReportActionsUtils.getWorkspaceFrequencyUpdateMessage(lastAction); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { - result.alternateText = Localize.translateLocal('workspaceActions.upgradedWorkspace'); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE)) { - result.alternateText = Localize.translateLocal('workspaceActions.downgradedWorkspace'); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) { + result.alternateText = `${lastActorDisplayName} ${getUpdateRoomDescriptionMessage(lastAction)}`; + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { + result.alternateText = getWorkspaceNameUpdatedMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION)) { + result.alternateText = getWorkspaceDescriptionUpdatedMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { + result.alternateText = getWorkspaceCurrencyUpdateMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { + result.alternateText = getWorkspaceFrequencyUpdateMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { + result.alternateText = translateLocal('workspaceActions.upgradedWorkspace'); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE)) { + result.alternateText = translateLocal('workspaceActions.downgradedWorkspace'); } else if ( - ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || - ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || - ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) || - ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) + isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || + isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || + isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) || + isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { - result.alternateText = ReportActionsUtils.getWorkspaceCategoryUpdateMessage(lastAction); - } else if (ReportActionsUtils.isTagModificationAction(lastAction?.actionName)) { - result.alternateText = PolicyUtils.getCleanedTagName(ReportActionsUtils.getWorkspaceTagUpdateMessage(lastAction) ?? ''); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE)) { - result.alternateText = ReportActionsUtils.getWorkspaceCustomUnitRateAddedMessage(lastAction); - } else if (ReportActionsUtils.isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { - result.alternateText = ReportActionsUtils.getWorkspaceReportFieldAddMessage(lastAction); + result.alternateText = getWorkspaceCategoryUpdateMessage(lastAction); + } else if (isTagModificationAction(lastAction?.actionName)) { + result.alternateText = getCleanedTagName(getWorkspaceTagUpdateMessage(lastAction) ?? ''); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE)) { + result.alternateText = getWorkspaceCustomUnitRateAddedMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { + result.alternateText = getWorkspaceReportFieldAddMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - result.alternateText = ReportActionsUtils.getWorkspaceUpdateFieldMessage(lastAction); + result.alternateText = getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(lastAction); + result.alternateText = getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogMaxExpenseAmountMessage(lastAction); + result.alternateText = getPolicyChangeLogMaxExpenseAmountMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogDefaultBillableMessage(lastAction); + result.alternateText = getPolicyChangeLogDefaultBillableMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogDefaultTitleEnforcedMessage(lastAction); + result.alternateText = getPolicyChangeLogDefaultTitleEnforcedMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { - result.alternateText = Localize.translateLocal('workspace.invite.leftWorkspace'); - } else if (ReportActionsUtils.isCardIssuedAction(lastAction)) { - result.alternateText = ReportActionsUtils.getCardIssuedMessage(lastAction); + result.alternateText = translateLocal('workspace.invite.leftWorkspace'); + } else if (isCardIssuedAction(lastAction)) { + result.alternateText = getCardIssuedMessage(lastAction); } else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) { result.alternateText = ReportUtils.formatReportLastMessageText(Parser.htmlToText(`${lastActorDisplayName}: ${lastMessageText}`)); - } else if (lastAction && ReportActionsUtils.isOldDotReportAction(lastAction)) { - result.alternateText = ReportActionsUtils.getMessageOfOldDotReportAction(lastAction); + } else if (lastAction && isOldDotReportAction(lastAction)) { + result.alternateText = getMessageOfOldDotReportAction(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogAddEmployeeMessage(lastAction); + result.alternateText = getPolicyChangeLogAddEmployeeMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogChangeRoleMessage(lastAction); + result.alternateText = getPolicyChangeLogChangeRoleMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { - result.alternateText = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(lastAction); + result.alternateText = getPolicyChangeLogDeleteMemberMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { - result.alternateText = ReportActionsUtils.getReportActionMessageText(lastAction) ?? ''; + result.alternateText = getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { - result.alternateText = ReportActionsUtils.getRemovedConnectionMessage(lastAction); + result.alternateText = getRemovedConnectionMessage(lastAction); } else { result.alternateText = lastMessageTextFromReport.length > 0 ? ReportUtils.formatReportLastMessageText(Parser.htmlToText(lastMessageText)) - : ReportActionsUtils.getLastVisibleMessage(report.reportID, result.isAllowedToComment, {}, lastAction)?.lastMessageText; + : getLastVisibleMessage(report.reportID, result.isAllowedToComment, {}, lastAction)?.lastMessageText; if (!result.alternateText) { - result.alternateText = ReportUtils.formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? Localize.translateLocal('report.noActivityYet')); + result.alternateText = ReportUtils.formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? translateLocal('report.noActivityYet')); } } } else { if (!lastMessageText) { - lastMessageText = ReportUtils.formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? Localize.translateLocal('report.noActivityYet')); + lastMessageText = ReportUtils.formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? translateLocal('report.noActivityYet')); } result.alternateText = ReportUtils.formatReportLastMessageText(Parser.htmlToText(lastMessageText)) || formattedLogin; } @@ -595,9 +629,9 @@ function getWelcomeMessage(report: OnyxEntry, policy: OnyxEntry) welcomeMessage.messageHtml = policy.description; welcomeMessage.messageText = Parser.htmlToText(welcomeMessage.messageHtml); } else { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne'); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo'); - welcomeMessage.phrase3 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartOne'); + welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo'); + welcomeMessage.phrase3 = translateLocal('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree'); welcomeMessage.messageText = ensureSingleSpacing( `${welcomeMessage.phrase1} ${ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)} ${welcomeMessage.phrase2} ${ReportUtils.getPolicyName(report)} ${ welcomeMessage.phrase3 @@ -608,24 +642,21 @@ function getWelcomeMessage(report: OnyxEntry, policy: OnyxEntry) } if (ReportUtils.isSelfDM(report)) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistorySelfDM'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistorySelfDM'); welcomeMessage.messageText = welcomeMessage.phrase1; return welcomeMessage; } if (ReportUtils.isSystemChat(report)) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistorySystemDM'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistorySystemDM'); welcomeMessage.messageText = welcomeMessage.phrase1; return welcomeMessage; } - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistory'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistory'); const participantAccountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(report, undefined, undefined, true); const isMultipleParticipant = participantAccountIDs.length > 1; - const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips( - OptionsListUtils.getPersonalDetailsForAccountIDs(participantAccountIDs, allPersonalDetails), - isMultipleParticipant, - ); + const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(getPersonalDetailsForAccountIDs(participantAccountIDs, allPersonalDetails), isMultipleParticipant); const displayNamesWithTooltipsText = displayNamesWithTooltips .map(({displayName, pronouns}, index) => { const formattedText = !pronouns ? displayName : `${displayName} (${pronouns})`; @@ -634,7 +665,7 @@ function getWelcomeMessage(report: OnyxEntry, policy: OnyxEntry) return `${formattedText}.`; } if (index === displayNamesWithTooltips.length - 2) { - return `${formattedText} ${Localize.translateLocal('common.and')}`; + return `${formattedText} ${translateLocal('common.and')}`; } if (index < displayNamesWithTooltips.length - 2) { return `${formattedText},`; @@ -662,35 +693,35 @@ function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { } if (report?.private_isArchived) { - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartOne'); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartTwo'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfArchivedRoomPartOne'); + welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfArchivedRoomPartTwo'); } else if (ReportUtils.isDomainRoom(report)) { welcomeMessage.showReportName = false; - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryDomainRoomPartOne', {domainRoom: report?.reportName ?? ''}); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryDomainRoomPartTwo'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryDomainRoomPartOne', {domainRoom: report?.reportName ?? ''}); + welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryDomainRoomPartTwo'); } else if (ReportUtils.isAdminRoom(report)) { welcomeMessage.showReportName = false; - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartOne', {workspaceName}); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartTwo'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartOne', {workspaceName}); + welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartTwo'); } else if (ReportUtils.isAnnounceRoom(report)) { welcomeMessage.showReportName = false; - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName}); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartTwo'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName}); + welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartTwo'); } else if (ReportUtils.isInvoiceRoom(report)) { welcomeMessage.showReportName = false; - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryInvoiceRoomPartOne'); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryInvoiceRoomPartTwo'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryInvoiceRoomPartOne'); + welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryInvoiceRoomPartTwo'); const payer = report?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL ? ReportUtils.getDisplayNameForParticipant(report?.invoiceReceiver?.accountID) - : PolicyUtils.getPolicy(report?.invoiceReceiver?.policyID)?.name; + : getPolicy(report?.invoiceReceiver?.policyID)?.name; const receiver = ReportUtils.getPolicyName(report); - welcomeMessage.messageText = `${welcomeMessage.phrase1}${payer} ${Localize.translateLocal('common.and')} ${receiver}${welcomeMessage.phrase2}`; + welcomeMessage.messageText = `${welcomeMessage.phrase1}${payer} ${translateLocal('common.and')} ${receiver}${welcomeMessage.phrase2}`; return welcomeMessage; } else { // Message for user created rooms or other room types. - welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartOne'); - welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartTwo'); + welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartOne'); + welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartTwo'); } welcomeMessage.messageText = ensureSingleSpacing(`${welcomeMessage.phrase1} ${welcomeMessage.showReportName ? ReportUtils.getReportName(report) : ''} ${welcomeMessage.phrase2 ?? ''}`); diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 057b5d72e5a4..2cea58bdf7e1 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -20,7 +20,7 @@ import {translateLocal} from '@libs/Localize'; import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage'; import Navigation from '@libs/Navigation/Navigation'; import Parser from '@libs/Parser'; -import * as PolicyUtils from '@libs/PolicyUtils'; +import {getCleanedTagName} from '@libs/PolicyUtils'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; import { getActionableMentionWhisperMessage, @@ -510,7 +510,7 @@ const ContextMenuActions: ContextMenuAction[] = [ ) { Clipboard.setString(getWorkspaceCategoryUpdateMessage(reportAction)); } else if (isTagModificationAction(reportAction.actionName)) { - Clipboard.setString(PolicyUtils.getCleanedTagName(getWorkspaceTagUpdateMessage(reportAction))); + Clipboard.setString(getCleanedTagName(getWorkspaceTagUpdateMessage(reportAction))); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { Clipboard.setString(getWorkspaceCustomUnitRateAddedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 90e2cd2857f8..aa412f547242 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -830,10 +830,6 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { children = ; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { - children = ; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { - children = ; } else if ( action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || From 5eb9ecf1f34b57a9c414bc7f28c4c433f3780035 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 21 Jan 2025 04:23:11 +0530 Subject: [PATCH 26/38] fix namespace import issue. Signed-off-by: krishna2323 --- .../home/report/PureReportActionItem.tsx | 317 ++++++++++-------- 1 file changed, 180 insertions(+), 137 deletions(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index aa412f547242..6d6464a7cad7 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -38,22 +38,90 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import {openPersonalBankAccountSetupView} from '@libs/actions/BankAccounts'; import ControlSelection from '@libs/ControlSelection'; -import * as DeviceCapabilities from '@libs/DeviceCapabilities'; -import * as ErrorUtils from '@libs/ErrorUtils'; +import {canUseTouchScreen} from '@libs/DeviceCapabilities'; +import {getLatestErrorMessageField} from '@libs/ErrorUtils'; +import type {OnyxDataWithErrors} from '@libs/ErrorUtils'; import focusComposerWithDelay from '@libs/focusComposerWithDelay'; -import * as LocalePhoneNumber from '@libs/LocalePhoneNumber'; +import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Navigation from '@libs/Navigation/Navigation'; import Permissions from '@libs/Permissions'; -import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; -import * as PolicyUtils from '@libs/PolicyUtils'; -import * as ReportActionsUtils from '@libs/ReportActionsUtils'; -import * as ReportUtils from '@libs/ReportUtils'; +import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; +import {getCleanedTagName} from '@libs/PolicyUtils'; +import { + extractLinksFromMessageHtml, + getDismissedViolationMessageText, + getIOUReportIDFromReportActionPreview, + getOriginalMessage, + getPolicyChangeLogAddEmployeeMessage, + getPolicyChangeLogChangeRoleMessage, + getPolicyChangeLogDefaultBillableMessage, + getPolicyChangeLogDefaultTitleEnforcedMessage, + getPolicyChangeLogDeleteMemberMessage, + getPolicyChangeLogMaxExpenseAmountMessage, + getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, + getRemovedConnectionMessage, + getRemovedFromApprovalChainMessage, + getRenamedAction, + getReportActionMessage, + getReportActionText, + getWhisperedTo, + getWorkspaceCategoryUpdateMessage, + getWorkspaceCurrencyUpdateMessage, + getWorkspaceCustomUnitRateAddedMessage, + getWorkspaceDescriptionUpdatedMessage, + getWorkspaceFrequencyUpdateMessage, + getWorkspaceNameUpdatedMessage, + getWorkspaceReportFieldAddMessage, + getWorkspaceTagUpdateMessage, + getWorkspaceUpdateFieldMessage, + isActionableAddPaymentCard, + isActionableJoinRequest, + isActionableMentionWhisper, + isActionableReportMentionWhisper, + isActionableTrackExpense, + isActionOfType, + isAddCommentAction, + isChronosOOOListAction, + isCreatedTaskReportAction, + isDeletedAction, + isDeletedParentAction as isDeletedParentActionReportActionsUtils, + isMessageDeleted, + isMoneyRequestAction, + isPendingRemove, + isReimbursementDeQueuedAction, + isReimbursementQueuedAction, + isRenamedAction, + isTagModificationAction, + isTaskAction, + isTripPreview, + isUnapprovedAction, + isWhisperActionTargetedToOthers, +} from '@libs/ReportActionsUtils'; +import { + canWriteInReport, + chatIncludesConcierge, + getDisplayNamesWithTooltips, + getIconsForParticipants, + getIOUApprovedMessage, + getIOUForwardedMessage, + getIOUSubmittedMessage, + getIOUUnapprovedMessage, + getReportAutomaticallyApprovedMessage, + getReportAutomaticallySubmittedMessage, + getWhisperDisplayNames, + isArchivedNonExpenseReport, + isChatThread, + isCompletedTaskReport, + isReportMessageAttachment, + isTaskReport, + shouldDisplayThreadReplies as shouldDisplayThreadRepliesReportUtils, +} from '@libs/ReportUtils'; import type {MissingPaymentMethod} from '@libs/ReportUtils'; import SelectionScraper from '@libs/SelectionScraper'; import shouldRenderAddPaymentCard from '@libs/shouldRenderAppPaymentCard'; import {ReactionListContext} from '@pages/home/ReportScreenContext'; -import * as BankAccounts from '@userActions/BankAccounts'; import * as EmojiPickerAction from '@userActions/EmojiPickerAction'; import * as Member from '@userActions/Policy/Member'; import * as Report from '@userActions/Report'; @@ -314,31 +382,27 @@ function PureReportActionItem({ const prevDraftMessage = usePrevious(draftMessage); const isReportActionLinked = linkedReportActionID && action.reportActionID && linkedReportActionID === action.reportActionID; const reportScrollManager = useReportScrollManager(); - const isActionableWhisper = - ReportActionsUtils.isActionableMentionWhisper(action) || ReportActionsUtils.isActionableTrackExpense(action) || ReportActionsUtils.isActionableReportMentionWhisper(action); - const originalMessage = ReportActionsUtils.getOriginalMessage(action); + const isActionableWhisper = isActionableMentionWhisper(action) || isActionableTrackExpense(action) || isActionableReportMentionWhisper(action); + const originalMessage = getOriginalMessage(action); const highlightedBackgroundColorIfNeeded = useMemo( () => (isReportActionLinked ? StyleUtils.getBackgroundColorStyle(theme.messageHighlightBG) : {}), [StyleUtils, isReportActionLinked, theme.messageHighlightBG], ); - const isDeletedParentAction = ReportActionsUtils.isDeletedParentAction(action); + const isDeletedParentAction = isDeletedParentActionReportActionsUtils(action); const isOriginalMessageAnObject = originalMessage && typeof originalMessage === 'object'; const hasResolutionInOriginalMessage = isOriginalMessageAnObject && 'resolution' in originalMessage; const prevActionResolution = usePrevious(isActionableWhisper && hasResolutionInOriginalMessage ? originalMessage?.resolution : null); // IOUDetails only exists when we are sending money - const isSendingMoney = - ReportActionsUtils.isMoneyRequestAction(action) && - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && - ReportActionsUtils.getOriginalMessage(action)?.IOUDetails; + const isSendingMoney = isMoneyRequestAction(action) && getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && getOriginalMessage(action)?.IOUDetails; const updateHiddenState = useCallback( (isHiddenValue: boolean) => { setIsHidden(isHiddenValue); const message = Array.isArray(action.message) ? action.message?.at(-1) : action.message; - const isAttachment = ReportUtils.isReportMessageAttachment(message); + const isAttachment = isReportMessageAttachment(message); if (!isAttachment) { return; } @@ -387,7 +451,7 @@ function PureReportActionItem({ return; } - const urls = ReportActionsUtils.extractLinksFromMessageHtml(action); + const urls = extractLinksFromMessageHtml(action); if (lodashIsEqual(downloadedPreviews.current, urls) || action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { return; } @@ -397,7 +461,7 @@ function PureReportActionItem({ }, [action, reportID]); useEffect(() => { - if (draftMessage === undefined || !ReportActionsUtils.isDeletedAction(action)) { + if (draftMessage === undefined || !isDeletedAction(action)) { return; } deleteReportActionDraft(reportID, action); @@ -405,7 +469,7 @@ function PureReportActionItem({ // Hide the message if it is being moderated for a higher offense, or is hidden by a moderator // Removed messages should not be shown anyway and should not need this flow - const latestDecision = ReportActionsUtils.getReportActionMessage(action)?.moderationDecision?.decision ?? ''; + const latestDecision = getReportActionMessage(action)?.moderationDecision?.decision ?? ''; useEffect(() => { if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT) { return; @@ -419,10 +483,7 @@ function PureReportActionItem({ } setModerationDecision(latestDecision); - if ( - ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && - !ReportActionsUtils.isPendingRemove(action) - ) { + if (![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === latestDecision) && !isPendingRemove(action)) { setIsHidden(true); return; } @@ -433,7 +494,7 @@ function PureReportActionItem({ setIsContextMenuActive(ReportActionContextMenu.isActiveReportAction(action.reportActionID)); }, [action.reportActionID]); - const disabledActions = useMemo(() => (!ReportUtils.canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]); + const disabledActions = useMemo(() => (!canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]); /** * Show the ReportActionContextMenu modal popover. @@ -522,7 +583,7 @@ function PureReportActionItem({ const mentionReportContextValue = useMemo(() => ({currentReportID: report?.reportID ?? '-1'}), [report?.reportID]); const actionableItemButtons: ActionableItem[] = useMemo(() => { - if (ReportActionsUtils.isActionableAddPaymentCard(action) && userBillingFundID === undefined && shouldRenderAddPaymentCard()) { + if (isActionableAddPaymentCard(action) && userBillingFundID === undefined && shouldRenderAddPaymentCard()) { return [ { text: 'subscription.cardSection.addCardButton', @@ -536,12 +597,12 @@ function PureReportActionItem({ ]; } - if (!isActionableWhisper && (!ReportActionsUtils.isActionableJoinRequest(action) || ReportActionsUtils.getOriginalMessage(action)?.choice !== ('' as JoinWorkspaceResolution))) { + if (!isActionableWhisper && (!isActionableJoinRequest(action) || getOriginalMessage(action)?.choice !== ('' as JoinWorkspaceResolution))) { return []; } - if (ReportActionsUtils.isActionableTrackExpense(action)) { - const transactionID = ReportActionsUtils.getOriginalMessage(action)?.transactionID; + if (isActionableTrackExpense(action)) { + const transactionID = getOriginalMessage(action)?.transactionID; return [ { text: 'actionableMentionTrackExpense.submit', @@ -578,7 +639,7 @@ function PureReportActionItem({ ]; } - if (ReportActionsUtils.isActionableJoinRequest(action)) { + if (isActionableJoinRequest(action)) { return [ { text: 'actionableMentionJoinWorkspaceOptions.accept', @@ -594,7 +655,7 @@ function PureReportActionItem({ ]; } - if (ReportActionsUtils.isActionableReportMentionWhisper(action)) { + if (isActionableReportMentionWhisper(action)) { return [ { text: 'common.yes', @@ -646,19 +707,19 @@ function PureReportActionItem({ // Show the MoneyRequestPreview for when expense is present if ( - ReportActionsUtils.isMoneyRequestAction(action) && - ReportActionsUtils.getOriginalMessage(action) && + isMoneyRequestAction(action) && + getOriginalMessage(action) && // For the pay flow, we only want to show MoneyRequestAction when sending money. When paying, we display a regular system message - (ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE || - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT || - ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) + (getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE || + getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.SPLIT || + getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) ) { // There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID - const iouReportID = ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ? ReportActionsUtils.getOriginalMessage(action)?.IOUReportID?.toString() ?? '-1' : '-1'; + const iouReportID = getOriginalMessage(action)?.IOUReportID ? getOriginalMessage(action)?.IOUReportID?.toString() ?? '-1' : '-1'; children = ( ); - } else if (ReportActionsUtils.isTripPreview(action)) { + } else if (isTripPreview(action)) { children = ( ); - } else if (ReportActionsUtils.isTaskAction(action)) { + } else if (isTaskAction(action)) { children = ; - } else if (ReportActionsUtils.isCreatedTaskReportAction(action)) { + } else if (isCreatedTaskReportAction(action)) { children = ( ); - } else if (ReportActionsUtils.isReimbursementQueuedAction(action)) { - const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; - const submitterDisplayName = LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[linkedReport?.ownerAccountID ?? -1])); - const paymentType = ReportActionsUtils.getOriginalMessage(action)?.paymentType ?? ''; + } else if (isReimbursementQueuedAction(action)) { + const linkedReport = isChatThread(report) ? parentReport : report; + const submitterDisplayName = formatPhoneNumber(getDisplayNameOrDefault(personalDetails?.[linkedReport?.ownerAccountID ?? -1])); + const paymentType = getOriginalMessage(action)?.paymentType ?? ''; children = ( - BankAccounts.openPersonalBankAccountSetupView(Navigation.getTopmostReportId() ?? linkedReport?.reportID, undefined, undefined, isUserValidated) - } + onPress={() => openPersonalBankAccountSetupView(Navigation.getTopmostReportId() ?? linkedReport?.reportID, undefined, undefined, isUserValidated)} pressOnEnter large /> @@ -764,39 +823,36 @@ function PureReportActionItem({ ); - } else if (ReportActionsUtils.isReimbursementDeQueuedAction(action)) { + } else if (isReimbursementDeQueuedAction(action)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) { children = ; - } else if ( - ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || - ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED) - ) { - const wasSubmittedViaHarvesting = ReportActionsUtils.getOriginalMessage(action)?.harvesting ?? false; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED)) { + const wasSubmittedViaHarvesting = getOriginalMessage(action)?.harvesting ?? false; if (wasSubmittedViaHarvesting) { children = ( - ${ReportUtils.getReportAutomaticallySubmittedMessage(action)}`} /> + ${getReportAutomaticallySubmittedMessage(action)}`} /> ); } else { - children = ; + children = ; } - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.APPROVED)) { - const wasAutoApproved = ReportActionsUtils.getOriginalMessage(action)?.automaticAction ?? false; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.APPROVED)) { + const wasAutoApproved = getOriginalMessage(action)?.automaticAction ?? false; if (wasAutoApproved) { children = ( - ${ReportUtils.getReportAutomaticallyApprovedMessage(action)}`} /> + ${getReportAutomaticallyApprovedMessage(action)}`} /> ); } else { - children = ; + children = ; } - } else if (ReportActionsUtils.isUnapprovedAction(action)) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) { - const wasAutoForwarded = ReportActionsUtils.getOriginalMessage(action)?.automaticAction ?? false; + } else if (isUnapprovedAction(action)) { + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) { + const wasAutoForwarded = getOriginalMessage(action)?.automaticAction ?? false; if (wasAutoForwarded) { children = ( @@ -804,7 +860,7 @@ function PureReportActionItem({ ); } else { - children = ; + children = ; } } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { children = ; @@ -815,54 +871,54 @@ function PureReportActionItem({ } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) { children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { - children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - children = ; + children = ; } else if ( action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { - children = ; - } else if (ReportActionsUtils.isTagModificationAction(action.actionName)) { - children = ; + children = ; + } else if (isTagModificationAction(action.actionName)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE)) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED)) { - children = ; + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) { + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE)) { + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED)) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { - children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { - children = ; + children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { + children = ; } else if ( - ReportActionsUtils.isActionOfType( + isActionOfType( action, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED, CONST.REPORT.ACTIONS.TYPE.CARD_ISSUED_VIRTUAL, @@ -876,20 +932,19 @@ function PureReportActionItem({ policyID={report?.policyID} /> ); - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION)) { + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION)) { children = ; - } else if (ReportActionsUtils.isRenamedAction(action)) { - const message = ReportActionsUtils.getRenamedAction(action); + } else if (isRenamedAction(action)) { + const message = getRenamedAction(action); children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { - const {label, errorMessage} = ReportActionsUtils.getOriginalMessage(action) ?? {label: '', errorMessage: ''}; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { + const {label, errorMessage} = getOriginalMessage(action) ?? {label: '', errorMessage: ''}; children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { - children = ; + } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { + children = ; } else { const hasBeenFlagged = - ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && - !ReportActionsUtils.isPendingRemove(action); + ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && !isPendingRemove(action); children = ( @@ -924,7 +979,7 @@ function PureReportActionItem({ {actionableItemButtons.length > 0 && ( )} @@ -937,8 +992,7 @@ function PureReportActionItem({ index={index} ref={textInputRef} shouldDisableEmojiPicker={ - (ReportUtils.chatIncludesConcierge(report) && User.isBlockedFromConcierge(blockedFromConcierge)) || - ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) + (chatIncludesConcierge(report) && User.isBlockedFromConcierge(blockedFromConcierge)) || isArchivedNonExpenseReport(report, reportNameValuePairs) } isGroupPolicyReport={!!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE} /> @@ -950,7 +1004,7 @@ function PureReportActionItem({ } const numberOfThreadReplies = action.childVisibleActionCount ?? 0; - const shouldDisplayThreadReplies = ReportUtils.shouldDisplayThreadReplies(action, isThreadReportParentAction); + const shouldDisplayThreadReplies = shouldDisplayThreadRepliesReportUtils(action, isThreadReportParentAction); const oldestFourAccountIDs = action.childOldestFourAccountIDs ?.split(',') @@ -966,7 +1020,7 @@ function PureReportActionItem({ !isEmptyObject(item))} /> )} - {!ReportActionsUtils.isMessageDeleted(action) && ( + {!isMessageDeleted(action) && ( @@ -1030,8 +1084,7 @@ function PureReportActionItem({ iouReport={iouReport} isHovered={hovered} hasBeenFlagged={ - ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && - !ReportActionsUtils.isPendingRemove(action) + ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && !isPendingRemove(action) } > {content} @@ -1043,9 +1096,7 @@ function PureReportActionItem({ }; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { - const transactionID = ReportActionsUtils.isMoneyRequestAction(parentReportActionForTransactionThread) - ? ReportActionsUtils.getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID - : '-1'; + const transactionID = isMoneyRequestAction(parentReportActionForTransactionThread) ? getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID : '-1'; return ( ); } - if (ReportActionsUtils.isChronosOOOListAction(action)) { + if (isChronosOOOListAction(action)) { return ( 1; - const iouReportID = - ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUReportID - ? (ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ?? '').toString() - : '-1'; + const iouReportID = isMoneyRequestAction(action) && getOriginalMessage(action)?.IOUReportID ? (getOriginalMessage(action)?.IOUReportID ?? '').toString() : '-1'; const transactionsWithReceipts = getTransactionsWithReceipts(iouReportID); const isWhisper = whisperedTo.length > 0 && transactionsWithReceipts.length === 0; const whisperedToPersonalDetails = isWhisper ? (Object.values(personalDetails ?? {}).filter((details) => whisperedTo.includes(details?.accountID ?? -1)) as OnyxTypes.PersonalDetails[]) : []; const isWhisperOnlyVisibleByUser = isWhisper && isCurrentUserTheOnlyParticipant(whisperedTo); - const displayNamesWithTooltips = isWhisper ? ReportUtils.getDisplayNamesWithTooltips(whisperedToPersonalDetails, isMultipleParticipant) : []; + const displayNamesWithTooltips = isWhisper ? getDisplayNamesWithTooltips(whisperedToPersonalDetails, isMultipleParticipant) : []; return ( shouldUseNarrowLayout && DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} + onPressIn={() => shouldUseNarrowLayout && canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} onSecondaryInteraction={showPopover} preventDefaultContextMenu={draftMessage === undefined && !hasErrors} @@ -1159,7 +1202,7 @@ function PureReportActionItem({ > { - const transactionID = ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID : undefined; + const transactionID = isMoneyRequestAction(action) ? getOriginalMessage(action)?.IOUTransactionID : undefined; if (transactionID) { clearError(transactionID); } @@ -1170,9 +1213,9 @@ function PureReportActionItem({ draftMessage !== undefined ? undefined : action.pendingAction ?? (action.isOptimisticAction ? CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD : undefined) } shouldHideOnDelete={!isThreadReportParentAction} - errors={linkedTransactionRouteError ?? ErrorUtils.getLatestErrorMessageField(action as ErrorUtils.OnyxDataWithErrors)} + errors={linkedTransactionRouteError ?? getLatestErrorMessageField(action as OnyxDataWithErrors)} errorRowStyles={[styles.ml10, styles.mr2]} - needsOffscreenAlphaCompositing={ReportActionsUtils.isMoneyRequestAction(action)} + needsOffscreenAlphaCompositing={isMoneyRequestAction(action)} shouldDisableStrikeThrough > {isWhisper && ( @@ -1189,7 +1232,7 @@ function PureReportActionItem({   { prevProps.report?.parentReportID === nextProps.report?.parentReportID && prevProps.report?.parentReportActionID === nextProps.report?.parentReportActionID && // TaskReport's created actions render the TaskView, which updates depending on certain fields in the TaskReport - ReportUtils.isTaskReport(prevProps.report) === ReportUtils.isTaskReport(nextProps.report) && + isTaskReport(prevProps.report) === isTaskReport(nextProps.report) && prevProps.action.actionName === nextProps.action.actionName && prevProps.report?.reportName === nextProps.report?.reportName && prevProps.report?.description === nextProps.report?.description && - ReportUtils.isCompletedTaskReport(prevProps.report) === ReportUtils.isCompletedTaskReport(nextProps.report) && + isCompletedTaskReport(prevProps.report) === isCompletedTaskReport(nextProps.report) && prevProps.report?.managerID === nextProps.report?.managerID && prevProps.shouldHideThreadDividerLine === nextProps.shouldHideThreadDividerLine && prevProps.report?.total === nextProps.report?.total && From 098b94902947edc07ef73fab2f580ecb5e5d3670 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 21 Jan 2025 04:52:56 +0530 Subject: [PATCH 27/38] fix namespace imports. Signed-off-by: krishna2323 --- src/libs/SidebarUtils.ts | 208 ++++++++++-------- .../home/report/PureReportActionItem.tsx | 30 +-- 2 files changed, 134 insertions(+), 104 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index ce22f60d7454..5723165808c7 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -57,8 +57,56 @@ import { isTaskAction, shouldReportActionBeVisibleAsLastAction, } from './ReportActionsUtils'; -import * as ReportUtils from './ReportUtils'; -import * as TaskUtils from './TaskUtils'; +import { + canUserPerformWriteAction as canUserPerformWriteActionReportUtils, + doesReportBelongToWorkspace, + formatReportLastMessageText, + getAllReportActionsErrorsAndReportActionThatRequiresAttention, + getAllReportErrors, + getChatRoomSubtitle, + getDisplayNameForParticipant, + getDisplayNamesWithTooltips, + getIcons, + getParticipantsAccountIDsForDisplay, + getPolicyName, + getReportDescription, + getReportName, + getReportNameValuePairs, + getReportNotificationPreference, + getReportParticipantsTitle, + hasReportErrorsOtherThanFailedReceipt, + isAdminRoom, + isAnnounceRoom, + isArchivedNonExpenseReport, + isChatRoom, + isChatThread, + isConciergeChatReport, + isDeprecatedGroupDM, + isDomainRoom, + isExpenseReport, + isExpenseRequest, + isGroupChat as isGroupChatReportUtils, + isHiddenForCurrentUser, + isInvoiceReport, + isInvoiceRoom, + isIOUOwnedByCurrentUser, + isJoinRequestInAdminRoom, + isMoneyRequestReport, + isOneTransactionThread, + isPolicyExpenseChat, + isSelfDM, + isSystemChat as isSystemChatReportUtils, + isTaskReport, + isThread, + isUnread, + isUnreadWithMention, + requiresAttentionFromCurrentUser, + shouldDisplayViolationsRBRInLHN, + shouldReportBeInOptionList, + shouldReportShowSubscript, +} from './ReportUtils'; +import type {OptionData} from './ReportUtils'; +import {getTaskReportActionMessage} from './TaskUtils'; type WelcomeMessage = {showReportName: boolean; phrase1?: string; phrase2?: string; phrase3?: string; messageText?: string; messageHtml?: string}; @@ -88,7 +136,7 @@ Onyx.connect({ } const reportID = extractCollectionItemID(key); const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report); + const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(report); const actionsArray: ReportAction[] = getSortedReportActions(Object.values(actions)); // The report is only visible if it is the last action not deleted that @@ -158,12 +206,12 @@ function getOrderedReportIDs( return; } const parentReportAction = getReportAction(report?.parentReportID, report?.parentReportActionID); - const doesReportHaveViolations = ReportUtils.shouldDisplayViolationsRBRInLHN(report, transactionViolations); - const isHidden = ReportUtils.isHiddenForCurrentUser(report); + const doesReportHaveViolations = shouldDisplayViolationsRBRInLHN(report, transactionViolations); + const isHidden = isHiddenForCurrentUser(report); const isFocused = report.reportID === currentReportId; - const hasErrorsOtherThanFailedReceipt = ReportUtils.hasReportErrorsOtherThanFailedReceipt(report, doesReportHaveViolations, transactionViolations); + const hasErrorsOtherThanFailedReceipt = hasReportErrorsOtherThanFailedReceipt(report, doesReportHaveViolations, transactionViolations); const isReportInAccessible = report?.errorFields?.notFound; - if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID, parentReportAction)) { + if (isOneTransactionThread(report.reportID, report.parentReportID, parentReportAction)) { return; } if (hasErrorsOtherThanFailedReceipt && !isReportInAccessible) { @@ -173,7 +221,7 @@ function getOrderedReportIDs( }); return; } - const isSystemChat = ReportUtils.isSystemChat(report); + const isSystemChat = isSystemChatReportUtils(report); const shouldOverrideHidden = hasValidDraftComment(report.reportID) || hasErrorsOtherThanFailedReceipt || @@ -181,13 +229,13 @@ function getOrderedReportIDs( isSystemChat || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing report.isPinned || - ReportUtils.requiresAttentionFromCurrentUser(report, parentReportAction); + requiresAttentionFromCurrentUser(report, parentReportAction); if (isHidden && !shouldOverrideHidden) { return; } if ( - ReportUtils.shouldReportBeInOptionList({ + shouldReportBeInOptionList({ report, currentReportId, isInFocusMode, @@ -220,29 +268,27 @@ function getOrderedReportIDs( const archivedReports: MiniReport[] = []; if (currentPolicyID || policyMemberAccountIDs.length > 0) { - reportsToDisplay = reportsToDisplay.filter( - (report) => report?.reportID === currentReportId || ReportUtils.doesReportBelongToWorkspace(report, policyMemberAccountIDs, currentPolicyID), - ); + reportsToDisplay = reportsToDisplay.filter((report) => report?.reportID === currentReportId || doesReportBelongToWorkspace(report, policyMemberAccountIDs, currentPolicyID)); } // There are a few properties that need to be calculated for the report which are used when sorting reports. reportsToDisplay.forEach((reportToDisplay) => { const report = reportToDisplay; const miniReport: MiniReport = { reportID: report?.reportID, - displayName: ReportUtils.getReportName(report), + displayName: getReportName(report), lastVisibleActionCreated: report?.lastVisibleActionCreated, }; const isPinned = report?.isPinned ?? false; const reportAction = getReportAction(report?.parentReportID, report?.parentReportActionID); - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); - if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) { + const reportNameValuePairs = getReportNameValuePairs(report?.reportID); + if (isPinned || requiresAttentionFromCurrentUser(report, reportAction)) { pinnedAndGBRReports.push(miniReport); } else if (report?.hasErrorsOtherThanFailedReceipt) { errorReports.push(miniReport); } else if (hasValidDraftComment(report?.reportID)) { draftReports.push(miniReport); - } else if (ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs)) { + } else if (isArchivedNonExpenseReport(report, reportNameValuePairs)) { archivedReports.push(miniReport); } else { nonArchivedReports.push(miniReport); @@ -290,11 +336,11 @@ function getReasonAndReportActionThatHasRedBrickRoad( hasViolations: boolean, transactionViolations?: OnyxCollection, ): ReasonAndReportActionThatHasRedBrickRoad | null { - const {reportAction} = ReportUtils.getAllReportActionsErrorsAndReportActionThatRequiresAttention(report, reportActions); - const errors = ReportUtils.getAllReportErrors(report, reportActions); + const {reportAction} = getAllReportActionsErrorsAndReportActionThatRequiresAttention(report, reportActions); + const errors = getAllReportErrors(report, reportActions); const hasErrors = Object.keys(errors).length !== 0; - if (ReportUtils.shouldDisplayViolationsRBRInLHN(report, transactionViolations)) { + if (shouldDisplayViolationsRBRInLHN(report, transactionViolations)) { return { reason: CONST.RBR_REASONS.HAS_TRANSACTION_THREAD_VIOLATIONS, }; @@ -345,7 +391,7 @@ function getOptionData({ lastMessageTextFromReport?: string; invoiceReceiverPolicy?: OnyxEntry; transactionViolations?: OnyxCollection; -}): ReportUtils.OptionData | undefined { +}): OptionData | undefined { // When a user signs out, Onyx is cleared. Due to the lazy rendering with a virtual list, it's possible for // this method to be called after the Onyx data has been cleared out. In that case, it's fine to do // a null check here and return early. @@ -353,10 +399,10 @@ function getOptionData({ return; } - const result: ReportUtils.OptionData = { + const result: OptionData = { text: '', alternateText: undefined, - allReportErrors: ReportUtils.getAllReportErrors(report, reportActions), + allReportErrors: getAllReportErrors(report, reportActions), brickRoadIndicator: null, tooltipText: null, subtitle: undefined, @@ -387,23 +433,23 @@ function getOptionData({ isConciergeChat: false, }; - const participantAccountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(report); - const visibleParticipantAccountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(report, true); + const participantAccountIDs = getParticipantsAccountIDsForDisplay(report); + const visibleParticipantAccountIDs = getParticipantsAccountIDsForDisplay(report, true); const participantPersonalDetailList = Object.values(getPersonalDetailsForAccountIDs(participantAccountIDs, personalDetails)); const personalDetail = participantPersonalDetailList.at(0) ?? ({} as PersonalDetails); - result.isThread = ReportUtils.isChatThread(report); - result.isChatRoom = ReportUtils.isChatRoom(report); - result.isTaskReport = ReportUtils.isTaskReport(report); - result.isInvoiceReport = ReportUtils.isInvoiceReport(report); + result.isThread = isChatThread(report); + result.isChatRoom = isChatRoom(report); + result.isTaskReport = isTaskReport(report); + result.isInvoiceReport = isInvoiceReport(report); result.parentReportAction = parentReportAction; // eslint-disable-next-line @typescript-eslint/naming-convention result.private_isArchived = report?.private_isArchived; - result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); - result.isExpenseRequest = ReportUtils.isExpenseRequest(report); - result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); - result.shouldShowSubscript = ReportUtils.shouldReportShowSubscript(report); + result.isPolicyExpenseChat = isPolicyExpenseChat(report); + result.isExpenseRequest = isExpenseRequest(report); + result.isMoneyRequestReport = isMoneyRequestReport(report); + result.shouldShowSubscript = shouldReportShowSubscript(report); result.pendingAction = report.pendingFields?.addWorkspaceRoom ?? report.pendingFields?.createChat; result.brickRoadIndicator = shouldShowRedBrickRoad(report, reportActions, hasViolations, transactionViolations) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; result.ownerAccountID = report.ownerAccountID; @@ -414,39 +460,34 @@ function getOptionData({ result.statusNum = report.statusNum; // When the only message of a report is deleted lastVisibileActionCreated is not reset leading to wrongly // setting it Unread so we add additional condition here to avoid empty chat LHN from being bold. - result.isUnread = ReportUtils.isUnread(report) && !!report.lastActorAccountID; - result.isUnreadWithMention = ReportUtils.isUnreadWithMention(report); + result.isUnread = isUnread(report) && !!report.lastActorAccountID; + result.isUnreadWithMention = isUnreadWithMention(report); result.isPinned = report.isPinned; result.iouReportID = report.iouReportID; result.keyForList = String(report.reportID); result.hasOutstandingChildRequest = report.hasOutstandingChildRequest; result.parentReportID = report.parentReportID; result.isWaitingOnBankAccount = report.isWaitingOnBankAccount; - result.notificationPreference = ReportUtils.getReportNotificationPreference(report); - result.isAllowedToComment = ReportUtils.canUserPerformWriteAction(report); + result.notificationPreference = getReportNotificationPreference(report); + result.isAllowedToComment = canUserPerformWriteActionReportUtils(report); result.chatType = report.chatType; result.isDeletedParentAction = report.isDeletedParentAction; - result.isSelfDM = ReportUtils.isSelfDM(report); - result.tooltipText = ReportUtils.getReportParticipantsTitle(visibleParticipantAccountIDs); + result.isSelfDM = isSelfDM(report); + result.tooltipText = getReportParticipantsTitle(visibleParticipantAccountIDs); result.hasOutstandingChildTask = report.hasOutstandingChildTask; result.hasParentAccess = report.hasParentAccess; - result.isConciergeChat = ReportUtils.isConciergeChatReport(report); + result.isConciergeChat = isConciergeChatReport(report); result.participants = report.participants; - const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat || ReportUtils.isExpenseReport(report); - const subtitle = ReportUtils.getChatRoomSubtitle(report); + const hasMultipleParticipants = participantPersonalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat || isExpenseReport(report); + const subtitle = getChatRoomSubtitle(report); const login = Str.removeSMSDomain(personalDetail?.login ?? ''); const status = personalDetail?.status ?? ''; const formattedLogin = Str.isSMSLogin(login) ? formatPhoneNumber(login) : login; // We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade. - const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips( - (participantPersonalDetailList || []).slice(0, 10), - hasMultipleParticipants, - undefined, - ReportUtils.isSelfDM(report), - ); + const displayNamesWithTooltips = getDisplayNamesWithTooltips((participantPersonalDetailList || []).slice(0, 10), hasMultipleParticipants, undefined, isSelfDM(report)); // If the last actor's details are not currently saved in Onyx Collection, // then try to get that from the last report action if that action is valid @@ -474,17 +515,16 @@ function getOptionData({ let lastMessageText = Str.removeSMSDomain(lastMessageTextFromReport); const lastAction = visibleReportActionItems[report.reportID]; - const isGroupChat = ReportUtils.isGroupChat(report) || ReportUtils.isDeprecatedGroupDM(report); + const isGroupChat = isGroupChatReportUtils(report) || isDeprecatedGroupDM(report); - const isThreadMessage = - ReportUtils.isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; + const isThreadMessage = isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage || isGroupChat) && !result.private_isArchived) { const lastActionName = lastAction?.actionName ?? report.lastActionType; if (isRenamedAction(lastAction)) { result.alternateText = getRenamedAction(lastAction); } else if (isTaskAction(lastAction)) { - result.alternateText = ReportUtils.formatReportLastMessageText(TaskUtils.getTaskReportActionMessage(lastAction).text); + result.alternateText = formatReportLastMessageText(getTaskReportActionMessage(lastAction).text); } else if (isInviteOrRemovedAction(lastAction)) { const lastActionOriginalMessage = lastAction?.actionName ? getOriginalMessage(lastAction) : null; const targetAccountIDs = lastActionOriginalMessage?.targetAccountIDs ?? []; @@ -494,7 +534,7 @@ function getOptionData({ ? translate(preferredLocale, 'workspace.invite.invited') : translate(preferredLocale, 'workspace.invite.removed'); const users = translate(preferredLocale, targetAccountIDsLength > 1 ? 'workspace.invite.users' : 'workspace.invite.user'); - result.alternateText = ReportUtils.formatReportLastMessageText(`${lastActorDisplayName} ${verb} ${targetAccountIDsLength} ${users}`); + result.alternateText = formatReportLastMessageText(`${lastActorDisplayName} ${verb} ${targetAccountIDsLength} ${users}`); const roomName = lastActionOriginalMessage?.roomName ?? ''; if (roomName) { @@ -546,7 +586,7 @@ function getOptionData({ } else if (isCardIssuedAction(lastAction)) { result.alternateText = getCardIssuedMessage(lastAction); } else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) { - result.alternateText = ReportUtils.formatReportLastMessageText(Parser.htmlToText(`${lastActorDisplayName}: ${lastMessageText}`)); + result.alternateText = formatReportLastMessageText(Parser.htmlToText(`${lastActorDisplayName}: ${lastMessageText}`)); } else if (lastAction && isOldDotReportAction(lastAction)) { result.alternateText = getMessageOfOldDotReportAction(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { @@ -562,22 +602,22 @@ function getOptionData({ } else { result.alternateText = lastMessageTextFromReport.length > 0 - ? ReportUtils.formatReportLastMessageText(Parser.htmlToText(lastMessageText)) + ? formatReportLastMessageText(Parser.htmlToText(lastMessageText)) : getLastVisibleMessage(report.reportID, result.isAllowedToComment, {}, lastAction)?.lastMessageText; if (!result.alternateText) { - result.alternateText = ReportUtils.formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? translateLocal('report.noActivityYet')); + result.alternateText = formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? translateLocal('report.noActivityYet')); } } } else { if (!lastMessageText) { - lastMessageText = ReportUtils.formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? translateLocal('report.noActivityYet')); + lastMessageText = formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? translateLocal('report.noActivityYet')); } - result.alternateText = ReportUtils.formatReportLastMessageText(Parser.htmlToText(lastMessageText)) || formattedLogin; + result.alternateText = formatReportLastMessageText(Parser.htmlToText(lastMessageText)) || formattedLogin; } - result.isIOUReportOwner = ReportUtils.isIOUOwnedByCurrentUser(result as Report); + result.isIOUReportOwner = isIOUOwnedByCurrentUser(result as Report); - if (ReportUtils.isJoinRequestInAdminRoom(report)) { + if (isJoinRequestInAdminRoom(report)) { result.isPinned = true; result.isUnread = true; result.brickRoadIndicator = CONST.BRICK_ROAD_INDICATOR_STATUS.INFO; @@ -589,21 +629,13 @@ function getOptionData({ result.phoneNumber = personalDetail?.phoneNumber ?? ''; } - const reportName = ReportUtils.getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy); + const reportName = getReportName(report, policy, undefined, undefined, invoiceReceiverPolicy); result.text = reportName; result.subtitle = subtitle; result.participantsList = participantPersonalDetailList; - result.icons = ReportUtils.getIcons( - report, - personalDetails, - personalDetail?.avatar, - personalDetail?.login, - personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID, - policy, - invoiceReceiverPolicy, - ); + result.icons = getIcons(report, personalDetails, personalDetail?.avatar, personalDetail?.login, personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID, policy, invoiceReceiverPolicy); result.displayNamesWithTooltips = displayNamesWithTooltips; if (status) { @@ -616,15 +648,15 @@ function getOptionData({ function getWelcomeMessage(report: OnyxEntry, policy: OnyxEntry): WelcomeMessage { const welcomeMessage: WelcomeMessage = {showReportName: true}; - if (ReportUtils.isChatThread(report) || ReportUtils.isTaskReport(report)) { + if (isChatThread(report) || isTaskReport(report)) { return welcomeMessage; } - if (ReportUtils.isChatRoom(report)) { + if (isChatRoom(report)) { return getRoomWelcomeMessage(report); } - if (ReportUtils.isPolicyExpenseChat(report)) { + if (isPolicyExpenseChat(report)) { if (policy?.description) { welcomeMessage.messageHtml = policy.description; welcomeMessage.messageText = Parser.htmlToText(welcomeMessage.messageHtml); @@ -633,30 +665,28 @@ function getWelcomeMessage(report: OnyxEntry, policy: OnyxEntry) welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartTwo'); welcomeMessage.phrase3 = translateLocal('reportActionsView.beginningOfChatHistoryPolicyExpenseChatPartThree'); welcomeMessage.messageText = ensureSingleSpacing( - `${welcomeMessage.phrase1} ${ReportUtils.getDisplayNameForParticipant(report?.ownerAccountID)} ${welcomeMessage.phrase2} ${ReportUtils.getPolicyName(report)} ${ - welcomeMessage.phrase3 - }`, + `${welcomeMessage.phrase1} ${getDisplayNameForParticipant(report?.ownerAccountID)} ${welcomeMessage.phrase2} ${getPolicyName(report)} ${welcomeMessage.phrase3}`, ); } return welcomeMessage; } - if (ReportUtils.isSelfDM(report)) { + if (isSelfDM(report)) { welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistorySelfDM'); welcomeMessage.messageText = welcomeMessage.phrase1; return welcomeMessage; } - if (ReportUtils.isSystemChat(report)) { + if (isSystemChatReportUtils(report)) { welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistorySystemDM'); welcomeMessage.messageText = welcomeMessage.phrase1; return welcomeMessage; } welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistory'); - const participantAccountIDs = ReportUtils.getParticipantsAccountIDsForDisplay(report, undefined, undefined, true); + const participantAccountIDs = getParticipantsAccountIDsForDisplay(report, undefined, undefined, true); const isMultipleParticipant = participantAccountIDs.length > 1; - const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(getPersonalDetailsForAccountIDs(participantAccountIDs, allPersonalDetails), isMultipleParticipant); + const displayNamesWithTooltips = getDisplayNamesWithTooltips(getPersonalDetailsForAccountIDs(participantAccountIDs, allPersonalDetails), isMultipleParticipant); const displayNamesWithTooltipsText = displayNamesWithTooltips .map(({displayName, pronouns}, index) => { const formattedText = !pronouns ? displayName : `${displayName} (${pronouns})`; @@ -684,10 +714,10 @@ function getWelcomeMessage(report: OnyxEntry, policy: OnyxEntry) */ function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { const welcomeMessage: WelcomeMessage = {showReportName: true}; - const workspaceName = ReportUtils.getPolicyName(report); + const workspaceName = getPolicyName(report); if (report?.description) { - welcomeMessage.messageHtml = ReportUtils.getReportDescription(report); + welcomeMessage.messageHtml = getReportDescription(report); welcomeMessage.messageText = Parser.htmlToText(welcomeMessage.messageHtml); return welcomeMessage; } @@ -695,27 +725,27 @@ function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { if (report?.private_isArchived) { welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfArchivedRoomPartOne'); welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfArchivedRoomPartTwo'); - } else if (ReportUtils.isDomainRoom(report)) { + } else if (isDomainRoom(report)) { welcomeMessage.showReportName = false; welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryDomainRoomPartOne', {domainRoom: report?.reportName ?? ''}); welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryDomainRoomPartTwo'); - } else if (ReportUtils.isAdminRoom(report)) { + } else if (isAdminRoom(report)) { welcomeMessage.showReportName = false; welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartOne', {workspaceName}); welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryAdminRoomPartTwo'); - } else if (ReportUtils.isAnnounceRoom(report)) { + } else if (isAnnounceRoom(report)) { welcomeMessage.showReportName = false; welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartOne', {workspaceName}); welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryAnnounceRoomPartTwo'); - } else if (ReportUtils.isInvoiceRoom(report)) { + } else if (isInvoiceRoom(report)) { welcomeMessage.showReportName = false; welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryInvoiceRoomPartOne'); welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryInvoiceRoomPartTwo'); const payer = report?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL - ? ReportUtils.getDisplayNameForParticipant(report?.invoiceReceiver?.accountID) + ? getDisplayNameForParticipant(report?.invoiceReceiver?.accountID) : getPolicy(report?.invoiceReceiver?.policyID)?.name; - const receiver = ReportUtils.getPolicyName(report); + const receiver = getPolicyName(report); welcomeMessage.messageText = `${welcomeMessage.phrase1}${payer} ${translateLocal('common.and')} ${receiver}${welcomeMessage.phrase2}`; return welcomeMessage; } else { @@ -723,7 +753,7 @@ function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartOne'); welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfChatHistoryUserRoomPartTwo'); } - welcomeMessage.messageText = ensureSingleSpacing(`${welcomeMessage.phrase1} ${welcomeMessage.showReportName ? ReportUtils.getReportName(report) : ''} ${welcomeMessage.phrase2 ?? ''}`); + welcomeMessage.messageText = ensureSingleSpacing(`${welcomeMessage.phrase1} ${welcomeMessage.showReportName ? getReportName(report) : ''} ${welcomeMessage.phrase2 ?? ''}`); return welcomeMessage; } diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 6d6464a7cad7..8ed42a67816f 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -39,6 +39,11 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {openPersonalBankAccountSetupView} from '@libs/actions/BankAccounts'; +import {hideEmojiPicker, isActive} from '@libs/actions/EmojiPickerAction'; +import {acceptJoinRequest, declineJoinRequest} from '@libs/actions/Policy/Member'; +import {expandURLPreview} from '@libs/actions/Report'; +import {isAnonymousUser, signOutAndRedirectToSignIn} from '@libs/actions/Session'; +import {isBlockedFromConcierge} from '@libs/actions/User'; import ControlSelection from '@libs/ControlSelection'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import {getLatestErrorMessageField} from '@libs/ErrorUtils'; @@ -122,12 +127,7 @@ import type {MissingPaymentMethod} from '@libs/ReportUtils'; import SelectionScraper from '@libs/SelectionScraper'; import shouldRenderAddPaymentCard from '@libs/shouldRenderAppPaymentCard'; import {ReactionListContext} from '@pages/home/ReportScreenContext'; -import * as EmojiPickerAction from '@userActions/EmojiPickerAction'; -import * as Member from '@userActions/Policy/Member'; -import * as Report from '@userActions/Report'; import type {IgnoreDirection} from '@userActions/ReportActions'; -import * as Session from '@userActions/Session'; -import * as User from '@userActions/User'; import CONST from '@src/CONST'; import type {IOUAction} from '@src/CONST'; import ROUTES from '@src/ROUTES'; @@ -419,8 +419,8 @@ function PureReportActionItem({ ReportActionContextMenu.hideContextMenu(); ReportActionContextMenu.hideDeleteModal(); } - if (EmojiPickerAction.isActive(action.reportActionID)) { - EmojiPickerAction.hideEmojiPicker(true); + if (isActive(action.reportActionID)) { + hideEmojiPicker(true); } if (reactionListRef?.current?.isActiveReportAction(action.reportActionID)) { reactionListRef?.current?.hideReactionList(); @@ -431,11 +431,11 @@ function PureReportActionItem({ useEffect(() => { // We need to hide EmojiPicker when this is a deleted parent action - if (!isDeletedParentAction || !EmojiPickerAction.isActive(action.reportActionID)) { + if (!isDeletedParentAction || !isActive(action.reportActionID)) { return; } - EmojiPickerAction.hideEmojiPicker(true); + hideEmojiPicker(true); }, [isDeletedParentAction, action.reportActionID]); useEffect(() => { @@ -457,7 +457,7 @@ function PureReportActionItem({ } downloadedPreviews.current = urls; - Report.expandURLPreview(reportID, action.reportActionID); + expandURLPreview(reportID, action.reportActionID); }, [action, reportID]); useEffect(() => { @@ -644,13 +644,13 @@ function PureReportActionItem({ { text: 'actionableMentionJoinWorkspaceOptions.accept', key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.ACCEPT}`, - onPress: () => Member.acceptJoinRequest(reportID, action), + onPress: () => acceptJoinRequest(reportID, action), isPrimary: true, }, { text: 'actionableMentionJoinWorkspaceOptions.decline', key: `${action.reportActionID}-actionableMentionJoinWorkspace-${CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION.DECLINE}`, - onPress: () => Member.declineJoinRequest(reportID, action), + onPress: () => declineJoinRequest(reportID, action), }, ]; } @@ -992,7 +992,7 @@ function PureReportActionItem({ index={index} ref={textInputRef} shouldDisableEmojiPicker={ - (chatIncludesConcierge(report) && User.isBlockedFromConcierge(blockedFromConcierge)) || isArchivedNonExpenseReport(report, reportNameValuePairs) + (chatIncludesConcierge(report) && isBlockedFromConcierge(blockedFromConcierge)) || isArchivedNonExpenseReport(report, reportNameValuePairs) } isGroupPolicyReport={!!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE} /> @@ -1027,11 +1027,11 @@ function PureReportActionItem({ emojiReactions={emojiReactions} shouldBlockReactions={hasErrors} toggleReaction={(emoji, ignoreSkinToneOnCompare) => { - if (Session.isAnonymousUser()) { + if (isAnonymousUser()) { hideContextMenu(false); InteractionManager.runAfterInteractions(() => { - Session.signOutAndRedirectToSignIn(); + signOutAndRedirectToSignIn(); }); } else { toggleReaction(emoji, ignoreSkinToneOnCompare); From 8a44aebd0e14d9a01dcc3d537623de4c8c61334d Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 21 Jan 2025 05:34:37 +0530 Subject: [PATCH 28/38] add translations for approval mode fields. Signed-off-by: krishna2323 --- src/CONST.ts | 14 +++++++------- src/languages/en.ts | 8 ++++++++ src/languages/es.ts | 8 ++++++++ src/libs/ReportActionsUtils.ts | 14 ++++++-------- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index e66bedbc13c5..b49c8be52c71 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2509,13 +2509,13 @@ const CONST = { SMARTREPORT: 'SMARTREPORT', BILLCOM: 'BILLCOM', }, - APPROVAL_MODE_VALUES: { - OPTIONAL: 'Submit and Close', - BASIC: 'Submit and Approve', - ADVANCED: 'ADVANCED', - DYNAMICEXTERNAL: 'DYNAMIC_EXTERNAL', - SMARTREPORT: 'SMARTREPORT', - BILLCOM: 'BILLCOM', + APPROVAL_MODE_TRANSLATION_KEYS: { + OPTIONAL: 'submitAndClose', + BASIC: 'submitAndApprove', + ADVANCED: 'advanced', + DYNAMICEXTERNAL: 'dynamictExternal', + SMARTREPORT: 'smartReport', + BILLCOM: 'billcom', }, ROOM_PREFIX: '#', CUSTOM_UNIT_RATE_BASE_OFFSET: 100, diff --git a/src/languages/en.ts b/src/languages/en.ts index 92d9999bc5c2..36b043441e54 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4619,6 +4619,14 @@ const translations = { public_announce: 'Public Announce', }, }, + workspaceApprovalModes: { + submitAndClose: 'Submit and Close', + submitAndApprove: 'Submit and Approve', + advanced: 'ADVANCED', + dynamictExternal: 'DYNAMIC_EXTERNAL', + smartReport: 'SMARTREPORT', + billcom: 'BILLCOM', + }, workspaceActions: { addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `added the category "${categoryName}"`, deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `removed the category "${categoryName}"`, diff --git a/src/languages/es.ts b/src/languages/es.ts index 7cb4e4838993..85605302e944 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4667,6 +4667,14 @@ const translations = { public_announce: 'Anuncio Público', }, }, + workspaceApprovalModes: { + submitAndClose: 'Enviar y Cerrar', + submitAndApprove: 'Enviar y Aprobar', + advanced: 'AVANZADO', + dynamictExternal: 'DINÁMICO_EXTERNO', + smartReport: 'INFORME_INTELIGENTE', + billcom: 'BILLCOM', + }, workspaceActions: { addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `agregó la categoría "${categoryName}"`, deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index ea534a78ec00..0fddaad97118 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1926,15 +1926,13 @@ function getWorkspaceReportFieldAddMessage(action: ReportAction): string { function getWorkspaceUpdateFieldMessage(action: ReportAction): string { const {newValue, oldValue, updatedField} = getOriginalMessage(action as ReportAction) ?? {}; - if ( - updatedField && - updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && - CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] && - CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES] - ) { + const newValueTranslationKey = CONST.POLICY.APPROVAL_MODE_TRANSLATION_KEYS[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_TRANSLATION_KEYS]; + const oldValueTranslationKey = CONST.POLICY.APPROVAL_MODE_TRANSLATION_KEYS[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_TRANSLATION_KEYS]; + + if (updatedField && updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && oldValueTranslationKey && newValueTranslationKey) { return translateLocal('workspaceActions.updateApprovalMode', { - oldValue: CONST.POLICY.APPROVAL_MODE_VALUES[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], - newValue: CONST.POLICY.APPROVAL_MODE_VALUES[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_VALUES], + newValue: translateLocal(`workspaceApprovalModes.${newValueTranslationKey}` as TranslationPaths), + oldValue: translateLocal(`workspaceApprovalModes.${oldValueTranslationKey}` as TranslationPaths), fieldName: updatedField, }); } From 3fb38707fe1c7572d68384daf3d2c88b24987334 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 21 Jan 2025 06:27:27 +0530 Subject: [PATCH 29/38] add translations for UPDATE_REPORT_FIELD & DELETE_REPORT_FIELD. Signed-off-by: krishna2323 --- src/languages/en.ts | 8 +++-- src/languages/es.ts | 8 +++-- src/languages/params.ts | 7 ++-- src/libs/ReportActionsUtils.ts | 32 ++++++++++++++++++- src/libs/SidebarUtils.ts | 6 ++++ .../report/ContextMenu/ContextMenuActions.tsx | 6 ++++ .../home/report/PureReportActionItem.tsx | 6 ++++ src/types/onyx/OriginalMessage.ts | 9 ++++++ 8 files changed, 75 insertions(+), 7 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 36b043441e54..c863fc7eae02 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -5,8 +5,8 @@ import type {Country} from '@src/CONST'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedOrDeletedPolicyReportFieldParams, AddedPolicyCustomUnitRateParams, - AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, @@ -178,6 +178,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyReportFieldDefaultValueParams, UpdatedPolicyTagFieldParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, @@ -4643,7 +4644,10 @@ const translations = { return `updated the tag "${tagName}" on the list "${tagListName}" by adding a ${updatedField} of "${newValue}"`; }, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `added a new "${customUnitName}" rate "${rateName}"`, - addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, + addedReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, + updateReportFieldDefaultValue: ({defaultValue, fieldName}: UpdatedPolicyReportFieldDefaultValueParams) => + `updated Report Field "${fieldName}"; set the default value to be "${defaultValue}"`, + deleteReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `removed ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => diff --git a/src/languages/es.ts b/src/languages/es.ts index 85605302e944..804bb3349c11 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4,8 +4,8 @@ import type en from './en'; import type { AccountOwnerParams, ActionsAreCurrentlyRestricted, + AddedOrDeletedPolicyReportFieldParams, AddedPolicyCustomUnitRateParams, - AddedPolicyReportFieldParams, AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, @@ -177,6 +177,7 @@ import type { UpdatedPolicyFieldWithValueParam, UpdatedPolicyFrequencyParams, UpdatedPolicyPreventSelfApprovalParams, + UpdatedPolicyReportFieldDefaultValueParams, UpdatedPolicyTagFieldParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, @@ -4690,7 +4691,10 @@ const translations = { } return `actualizó la etiqueta "${tagName}" en la lista "${tagListName}" añadiendo un ${updatedField} de "${newValue}"`; }, - addedReportField: ({fieldType, fieldName}: AddedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, + addedReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, + updateReportFieldDefaultValue: ({defaultValue, fieldName}: UpdatedPolicyReportFieldDefaultValueParams) => + `actualizó el campo del informe "${fieldName}"; estableció el valor predeterminado como "${defaultValue}"`, + deleteReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `eliminó el campo de informe ${fieldType} "${fieldName}"`, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `agregó una nueva tasa de "${rateName}" para "${customUnitName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, diff --git a/src/languages/params.ts b/src/languages/params.ts index 6723b8b7a882..6f57eb27d43a 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -302,7 +302,9 @@ type UpdatedPolicyCategoryNameParams = {oldName: string; newName?: string}; type AddedPolicyCustomUnitRateParams = {customUnitName: string; rateName: string}; -type AddedPolicyReportFieldParams = {fieldType: string; fieldName?: string}; +type AddedOrDeletedPolicyReportFieldParams = {fieldType: string; fieldName?: string}; + +type UpdatedPolicyReportFieldDefaultValueParams = {fieldName?: string; defaultValue?: string}; type UpdatedPolicyPreventSelfApprovalParams = {oldValue: string; newValue: string}; @@ -838,9 +840,10 @@ export type { UpdatedPolicyDescriptionParams, EditDestinationSubtitleParams, FlightLayoverParams, - AddedPolicyReportFieldParams, + AddedOrDeletedPolicyReportFieldParams, AddedPolicyCustomUnitRateParams, UpdatedPolicyTagParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagFieldParams, + UpdatedPolicyReportFieldDefaultValueParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 0fddaad97118..861bbd534c30 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -11,6 +11,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {Locale, OnyxInputOrEntry, PrivatePersonalDetails} from '@src/types/onyx'; import type {JoinWorkspaceResolution, OriginalMessageChangeLog, OriginalMessageExportIntegration} from '@src/types/onyx/OriginalMessage'; +import type {PolicyReportFieldType} from '@src/types/onyx/Policy'; import type Report from '@src/types/onyx/Report'; import type ReportAction from '@src/types/onyx/ReportAction'; import type {Message, OldDotReportAction, OriginalMessage, ReportActions} from '@src/types/onyx/ReportAction'; @@ -31,6 +32,7 @@ import {getPolicy, isPolicyAdmin as isPolicyAdminPolicyUtils} from './PolicyUtil import type {OptimisticIOUReportAction, PartialReportAction} from './ReportUtils'; import StringUtils from './StringUtils'; import {isOnHoldByTransactionID} from './TransactionUtils'; +import {getReportFieldAlternativeTextTranslationKey} from './WorkspaceReportFieldUtils'; type LastVisibleMessage = { lastMessageText: string; @@ -1916,7 +1918,33 @@ function getWorkspaceReportFieldAddMessage(action: ReportAction): string { if (fieldName && fieldType) { return translateLocal('workspaceActions.addedReportField', { fieldName, - fieldType, + fieldType: translateLocal(getReportFieldAlternativeTextTranslationKey(fieldType as PolicyReportFieldType)), + }); + } + + return getReportActionText(action); +} + +function getWorkspaceReportFieldUpdateMessage(action: ReportAction): string { + const {updateType, fieldName, defaultValue} = getOriginalMessage(action as ReportAction) ?? {}; + + if (updateType === 'updatedDefaultValue' && fieldName && defaultValue) { + return translateLocal('workspaceActions.updateReportFieldDefaultValue', { + fieldName, + defaultValue, + }); + } + + return getReportActionText(action); +} + +function getWorkspaceReportFieldDeleteMessage(action: ReportAction): string { + const {fieldType, fieldName} = getOriginalMessage(action as ReportAction) ?? {}; + + if (fieldType && fieldName) { + return translateLocal('workspaceActions.deleteReportField', { + fieldName, + fieldType: translateLocal(getReportFieldAlternativeTextTranslationKey(fieldType as PolicyReportFieldType)), }); } @@ -2259,6 +2287,8 @@ export { getWorkspaceReportFieldAddMessage, getWorkspaceCustomUnitRateAddedMessage, getWorkspaceTagUpdateMessage, + getWorkspaceReportFieldUpdateMessage, + getWorkspaceReportFieldDeleteMessage, }; export type {LastVisibleMessage}; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 5723165808c7..0ce6db622c11 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -46,6 +46,8 @@ import { getWorkspaceFrequencyUpdateMessage, getWorkspaceNameUpdatedMessage, getWorkspaceReportFieldAddMessage, + getWorkspaceReportFieldDeleteMessage, + getWorkspaceReportFieldUpdateMessage, getWorkspaceTagUpdateMessage, getWorkspaceUpdateFieldMessage, isActionOfType, @@ -571,6 +573,10 @@ function getOptionData({ result.alternateText = getWorkspaceCustomUnitRateAddedMessage(lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { result.alternateText = getWorkspaceReportFieldAddMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD)) { + result.alternateText = getWorkspaceReportFieldUpdateMessage(lastAction); + } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD)) { + result.alternateText = getWorkspaceReportFieldDeleteMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { result.alternateText = getWorkspaceUpdateFieldMessage(lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 2cea58bdf7e1..1cb17075c522 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -47,6 +47,8 @@ import { getWorkspaceDescriptionUpdatedMessage, getWorkspaceFrequencyUpdateMessage, getWorkspaceReportFieldAddMessage, + getWorkspaceReportFieldDeleteMessage, + getWorkspaceReportFieldUpdateMessage, getWorkspaceTagUpdateMessage, getWorkspaceUpdateFieldMessage, isActionableMentionWhisper, @@ -515,6 +517,10 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(getWorkspaceCustomUnitRateAddedMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { Clipboard.setString(getWorkspaceReportFieldAddMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) { + Clipboard.setString(getWorkspaceReportFieldUpdateMessage(reportAction)); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) { + Clipboard.setString(getWorkspaceReportFieldDeleteMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { setClipboardMessage(getWorkspaceUpdateFieldMessage(reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 8ed42a67816f..42883606fd6d 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -79,6 +79,8 @@ import { getWorkspaceFrequencyUpdateMessage, getWorkspaceNameUpdatedMessage, getWorkspaceReportFieldAddMessage, + getWorkspaceReportFieldDeleteMessage, + getWorkspaceReportFieldUpdateMessage, getWorkspaceTagUpdateMessage, getWorkspaceUpdateFieldMessage, isActionableAddPaymentCard, @@ -899,6 +901,10 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) { + children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) { + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 5e710c2a55b6..ca0e9724cdde 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -389,6 +389,15 @@ type OriginalMessagePolicyChangeLog = { /** Updated tag enabled/disabled value */ enabled?: boolean; + + /** Default value of a report field */ + defaultValue?: string; + + /** field ID of a report field */ + fieldID?: string; + + /** update type of a report field */ + updateType?: string; }; /** Model of `join policy changelog` report action */ From 7f8143dc0abf5986fad62d88d679bbfa915668be Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 30 Jan 2025 18:46:21 +0530 Subject: [PATCH 30/38] fix merge conflicts. Signed-off-by: krishna2323 --- src/libs/SidebarUtils.ts | 23 +++++++++---------- .../home/report/PureReportActionItem.tsx | 7 ++++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 0ce6db622c11..9d6b9f94e9b1 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -36,6 +36,7 @@ import { getRemovedConnectionMessage, getRenamedAction, getReportAction, + getReportActionMessage, getReportActionMessageText, getSortedReportActions, getUpdateRoomDescriptionMessage, @@ -60,7 +61,7 @@ import { shouldReportActionBeVisibleAsLastAction, } from './ReportActionsUtils'; import { - canUserPerformWriteAction as canUserPerformWriteActionReportUtils, + canUserPerformWriteAction as canUserPerformWriteActionUtil, doesReportBelongToWorkspace, formatReportLastMessageText, getAllReportActionsErrorsAndReportActionThatRequiresAttention, @@ -80,6 +81,7 @@ import { isAdminRoom, isAnnounceRoom, isArchivedNonExpenseReport, + isArchivedReportWithID, isChatRoom, isChatThread, isConciergeChatReport, @@ -87,7 +89,7 @@ import { isDomainRoom, isExpenseReport, isExpenseRequest, - isGroupChat as isGroupChatReportUtils, + isGroupChat as isGroupChatUtil, isHiddenForCurrentUser, isInvoiceReport, isInvoiceRoom, @@ -97,7 +99,7 @@ import { isOneTransactionThread, isPolicyExpenseChat, isSelfDM, - isSystemChat as isSystemChatReportUtils, + isSystemChat as isSystemChatUtil, isTaskReport, isThread, isUnread, @@ -138,7 +140,7 @@ Onyx.connect({ } const reportID = extractCollectionItemID(key); const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - const canUserPerformWriteAction = canUserPerformWriteActionReportUtils(report); + const canUserPerformWriteAction = canUserPerformWriteActionUtil(report); const actionsArray: ReportAction[] = getSortedReportActions(Object.values(actions)); // The report is only visible if it is the last action not deleted that @@ -223,7 +225,7 @@ function getOrderedReportIDs( }); return; } - const isSystemChat = isSystemChatReportUtils(report); + const isSystemChat = isSystemChatUtil(report); const shouldOverrideHidden = hasValidDraftComment(report.reportID) || hasErrorsOtherThanFailedReceipt || @@ -269,9 +271,6 @@ function getOrderedReportIDs( const nonArchivedReports: MiniReport[] = []; const archivedReports: MiniReport[] = []; - if (currentPolicyID || policyMemberAccountIDs.length > 0) { - reportsToDisplay = reportsToDisplay.filter((report) => report?.reportID === currentReportId || doesReportBelongToWorkspace(report, policyMemberAccountIDs, currentPolicyID)); - } // There are a few properties that need to be calculated for the report which are used when sorting reports. reportsToDisplay.forEach((reportToDisplay) => { const report = reportToDisplay; @@ -447,7 +446,7 @@ function getOptionData({ result.isInvoiceReport = isInvoiceReport(report); result.parentReportAction = parentReportAction; // eslint-disable-next-line @typescript-eslint/naming-convention - result.private_isArchived = report?.private_isArchived; + result.private_isArchived = reportNameValuePairs?.private_isArchived; result.isPolicyExpenseChat = isPolicyExpenseChat(report); result.isExpenseRequest = isExpenseRequest(report); result.isMoneyRequestReport = isMoneyRequestReport(report); @@ -517,7 +516,7 @@ function getOptionData({ let lastMessageText = Str.removeSMSDomain(lastMessageTextFromReport); const lastAction = visibleReportActionItems[report.reportID]; - const isGroupChat = isGroupChatReportUtils(report) || isDeprecatedGroupDM(report); + const isGroupChat = isGroupChatUtil(report) || isDeprecatedGroupDM(report); const isThreadMessage = isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage || isGroupChat) && !result.private_isArchived) { @@ -683,7 +682,7 @@ function getWelcomeMessage(report: OnyxEntry, policy: OnyxEntry) return welcomeMessage; } - if (isSystemChatReportUtils(report)) { + if (isSystemChatUtil(report)) { welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfChatHistorySystemDM'); welcomeMessage.messageText = welcomeMessage.phrase1; return welcomeMessage; @@ -728,7 +727,7 @@ function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { return welcomeMessage; } - if (report?.private_isArchived) { + if (isArchivedReportWithID(report?.reportID)) { welcomeMessage.phrase1 = translateLocal('reportActionsView.beginningOfArchivedRoomPartOne'); welcomeMessage.phrase2 = translateLocal('reportActionsView.beginningOfArchivedRoomPartTwo'); } else if (isDomainRoom(report)) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 42883606fd6d..7fc411f022c2 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -56,6 +56,8 @@ import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; import {getCleanedTagName} from '@libs/PolicyUtils'; import { extractLinksFromMessageHtml, + getAllReportActions, + getDeletedTransactionMessage, getDismissedViolationMessageText, getIOUReportIDFromReportActionPreview, getOriginalMessage, @@ -93,8 +95,9 @@ import { isChronosOOOListAction, isCreatedTaskReportAction, isDeletedAction, - isDeletedParentAction as isDeletedParentActionReportActionsUtils, + isDeletedParentAction as isDeletedParentActionUtils, isMessageDeleted, + isModifiedExpenseAction, isMoneyRequestAction, isPendingRemove, isReimbursementDeQueuedAction, @@ -392,7 +395,7 @@ function PureReportActionItem({ [StyleUtils, isReportActionLinked, theme.messageHighlightBG], ); - const isDeletedParentAction = isDeletedParentActionReportActionsUtils(action); + const isDeletedParentAction = isDeletedParentActionUtils(action); const isOriginalMessageAnObject = originalMessage && typeof originalMessage === 'object'; const hasResolutionInOriginalMessage = isOriginalMessageAnObject && 'resolution' in originalMessage; const prevActionResolution = usePrevious(isActionableWhisper && hasResolutionInOriginalMessage ? originalMessage?.resolution : null); From 8a13f734b29af40c78f98ab3e4d75899fb0c056e Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 30 Jan 2025 18:46:47 +0530 Subject: [PATCH 31/38] fix merge conflicts. Signed-off-by: krishna2323 --- src/pages/home/report/PureReportActionItem.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 7fc411f022c2..4f028eb303d4 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -126,7 +126,7 @@ import { isCompletedTaskReport, isReportMessageAttachment, isTaskReport, - shouldDisplayThreadReplies as shouldDisplayThreadRepliesReportUtils, + shouldDisplayThreadReplies as shouldDisplayThreadRepliesUtils, } from '@libs/ReportUtils'; import type {MissingPaymentMethod} from '@libs/ReportUtils'; import SelectionScraper from '@libs/SelectionScraper'; @@ -1013,7 +1013,7 @@ function PureReportActionItem({ } const numberOfThreadReplies = action.childVisibleActionCount ?? 0; - const shouldDisplayThreadReplies = shouldDisplayThreadRepliesReportUtils(action, isThreadReportParentAction); + const shouldDisplayThreadReplies = shouldDisplayThreadRepliesUtils(action, isThreadReportParentAction); const oldestFourAccountIDs = action.childOldestFourAccountIDs ?.split(',') From ab6c41fa0ce0cd2c3b4bcf3e93cdd0f5d9045a59 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 30 Jan 2025 19:16:14 +0530 Subject: [PATCH 32/38] fix tests. Signed-off-by: krishna2323 --- src/libs/SidebarUtils.ts | 3 --- src/pages/home/report/PureReportActionItem.tsx | 10 ---------- 2 files changed, 13 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 4018420cffe2..d3e524a0d88f 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -36,7 +36,6 @@ import { getRemovedConnectionMessage, getRenamedAction, getReportAction, - getReportActionMessage, getReportActionMessageText, getSortedReportActions, getUpdateRoomDescriptionMessage, @@ -45,7 +44,6 @@ import { getWorkspaceCustomUnitRateAddedMessage, getWorkspaceDescriptionUpdatedMessage, getWorkspaceFrequencyUpdateMessage, - getWorkspaceNameUpdatedMessage, getWorkspaceReportFieldAddMessage, getWorkspaceReportFieldDeleteMessage, getWorkspaceReportFieldUpdateMessage, @@ -60,7 +58,6 @@ import { isTaskAction, shouldReportActionBeVisibleAsLastAction, } from './ReportActionsUtils'; - import type {OptionData} from './ReportUtils'; import { canUserPerformWriteAction as canUserPerformWriteActionUtil, diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index b3002c2f6ffc..a77ce9950272 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -37,12 +37,6 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import {openPersonalBankAccountSetupView} from '@libs/actions/BankAccounts'; -import {hideEmojiPicker, isActive} from '@libs/actions/EmojiPickerAction'; -import {acceptJoinRequest, declineJoinRequest} from '@libs/actions/Policy/Member'; -import {expandURLPreview} from '@libs/actions/Report'; -import {isAnonymousUser, signOutAndRedirectToSignIn} from '@libs/actions/Session'; -import {isBlockedFromConcierge} from '@libs/actions/User'; import ControlSelection from '@libs/ControlSelection'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import type {OnyxDataWithErrors} from '@libs/ErrorUtils'; @@ -56,7 +50,6 @@ import {getCleanedTagName} from '@libs/PolicyUtils'; import { extractLinksFromMessageHtml, getAllReportActions, - getDeletedTransactionMessage, getDismissedViolationMessageText, getIOUReportIDFromReportActionPreview, getOriginalMessage, @@ -78,7 +71,6 @@ import { getWorkspaceCustomUnitRateAddedMessage, getWorkspaceDescriptionUpdatedMessage, getWorkspaceFrequencyUpdateMessage, - getWorkspaceNameUpdatedMessage, getWorkspaceReportFieldAddMessage, getWorkspaceReportFieldDeleteMessage, getWorkspaceReportFieldUpdateMessage, @@ -90,7 +82,6 @@ import { isActionableReportMentionWhisper, isActionableTrackExpense, isActionOfType, - isAddCommentAction, isChronosOOOListAction, isCreatedTaskReportAction, isDeletedAction, @@ -133,7 +124,6 @@ import type {MissingPaymentMethod} from '@libs/ReportUtils'; import SelectionScraper from '@libs/SelectionScraper'; import shouldRenderAddPaymentCard from '@libs/shouldRenderAppPaymentCard'; import {ReactionListContext} from '@pages/home/ReportScreenContext'; -import type {IgnoreDirection} from '@userActions/ReportActions'; import {openPersonalBankAccountSetupView} from '@userActions/BankAccounts'; import {hideEmojiPicker, isActive} from '@userActions/EmojiPickerAction'; import {acceptJoinRequest, declineJoinRequest} from '@userActions/Policy/Member'; From cb0c5a18be8d4eef243e139ea2a2d1d1696a18b5 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 3 Feb 2025 12:58:16 +0530 Subject: [PATCH 33/38] update english translations. Signed-off-by: krishna2323 --- src/languages/en.ts | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1bd17b719344..a218d4eb9bf5 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4698,32 +4698,34 @@ const translations = { updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'disabled' : 'enabled'} the category "${categoryName}"`, setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renamed the category "${oldName}" to "${newName}"`, addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `added the tag "${tagName}" to the list "${tagListName}"`, - updateTagName: ({tagListName, newName, oldName}: UpdatedPolicyTagNameParams) => `updated the tag list "${tagListName}" by changing the tag "${oldName}" to be "${newName}"`, + updateTagName: ({tagListName, newName, oldName}: UpdatedPolicyTagNameParams) => `updated the tag list "${tagListName}" by changing the tag "${oldName}" to "${newName}`, updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'enabled' : 'disabled'} the tag "${tagName}" on the list "${tagListName}"`, deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `removed the tag "${tagName}" from the list "${tagListName}"`, updateTag: ({tagListName, newValue, tagName, updatedField, oldValue}: UpdatedPolicyTagFieldParams) => { if (oldValue) { - return `updated the tag "${tagName}" on the list "${tagListName}" by changing the ${updatedField} from "${oldValue}" to "${newValue}"`; + return `updated the tag "${tagName}" on the list "${tagListName}" by changing the ${updatedField} to "${newValue}" (previously "${oldValue}")`; } return `updated the tag "${tagName}" on the list "${tagListName}" by adding a ${updatedField} of "${newValue}"`; }, addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `added a new "${customUnitName}" rate "${rateName}"`, addedReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `added ${fieldType} Report Field "${fieldName}"`, - updateReportFieldDefaultValue: ({defaultValue, fieldName}: UpdatedPolicyReportFieldDefaultValueParams) => - `updated Report Field "${fieldName}"; set the default value to be "${defaultValue}"`, + updateReportFieldDefaultValue: ({defaultValue, fieldName}: UpdatedPolicyReportFieldDefaultValueParams) => `set the default value of report field "${fieldName}" to "${defaultValue}"`, deleteReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `removed ${fieldType} Report Field "${fieldName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => - `updated "Prevent Self-Approval" from "${oldValue === 'true' ? 'Enabled' : 'Disabled'}" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}"`, + `updated "Prevent self-approval" to "${newValue === 'true' ? 'Enabled' : 'Disabled'}" (previously "${oldValue === 'true' ? 'Enabled' : 'Disabled'}")`, updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => - `changed the maximum receipt required expense amount from ${oldValue} to ${newValue}`, - updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `changed the maximum expense amount for violations from ${oldValue} to ${newValue}`, + `changed the maximum receipt required expense amount to ${newValue} (previously ${oldValue})`, + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => + `changed the maximum expense amount for violations to ${newValue} (previously ${oldValue})`, updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => - `updated "Max Expense Age (Days)" from "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" to "${newValue}"`, - updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `updated "Re-bill expenses to clients" from "${oldValue}" to "${newValue}"`, - updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `turned "Enforce Default Report Title" ${value ? 'on' : 'off'}`, + `updated "Max expense age (days)" to "${newValue}" (previously "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}")`, + updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `updated "Re-bill expenses to clients" to "${newValue}" (previously "${oldValue}")`, + updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `turned "Enforce default report titles" ${value ? 'on' : 'off'}`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `updated the name of this workspace to "${newName}" (previously "${oldName}")`, updateWorkspaceDescription: ({newDescription, oldDescription}: UpdatedPolicyDescriptionParams) => - !oldDescription ? `set the description of this workspace to "${newDescription}"` : `updated the description of this workspace from "${oldDescription}" to "${newDescription}"`, + !oldDescription + ? `set the description of this workspace to "${newDescription}"` + : `updated the description of this workspace to "${newDescription}" (previously "${oldDescription}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; if (submittersNames.length === 1) { @@ -4738,9 +4740,10 @@ const translations = { other: `removed you from ${joinedNames}'s approval workflows and workspace chats. Previously submitted reports will remain available for approval in your Inbox.`, }; }, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `updated the default currency from ${oldCurrency} to ${newCurrency}`, - updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => `updated the auto-reporting frequency from "${oldFrequency}" to "${newFrequency}"`, - updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `updated the Approval Mode from "${oldValue}" to "${newValue}".`, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `updated the default currency to ${newCurrency} (previously ${oldCurrency})`, + updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => + `updated the auto-reporting frequency to "${newFrequency}" (previously "${oldFrequency}")`, + updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `updated the approval mode to "${newValue}" (previously "${oldValue}")`, upgradedWorkspace: 'upgraded this workspace to the Control plan', downgradedWorkspace: 'downgraded this workspace to the Collect plan', }, From cd5e89ee829c51bc3acc522b0a562fa6c4d64dc9 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 3 Feb 2025 13:06:29 +0530 Subject: [PATCH 34/38] update spanish translations. Signed-off-by: krishna2323 --- src/languages/es.ts | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 1d9e538aadf2..1f42c2eb0c2a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4742,38 +4742,40 @@ const translations = { billcom: 'BILLCOM', }, workspaceActions: { - addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `agregó la categoría "${categoryName}"`, + addCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `añadió la categoría "${categoryName}""`, deleteCategory: ({categoryName}: UpdatedPolicyCategoryParams) => `eliminó la categoría "${categoryName}"`, updateCategory: ({oldValue, categoryName}: UpdatedPolicyCategoryParams) => `${oldValue ? 'deshabilitó' : 'habilitó'} la categoría "${categoryName}"`, - setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `Renombró la categoría "${oldName}" a "${newName}".`, - addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `agregó la etiqueta "${tagName}" a la lista "${tagListName}"`, + setCategoryName: ({oldName, newName}: UpdatedPolicyCategoryNameParams) => `renombró la categoría "${oldName}" a "${newName}`, + addTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `añadió la etiqueta "${tagName}" a la lista "${tagListName}"`, updateTagName: ({tagListName, newName, oldName}: UpdatedPolicyTagNameParams) => `actualizó la lista de etiquetas "${tagListName}" cambiando la etiqueta "${oldName}" a "${newName}"`, updateTagEnabled: ({tagListName, tagName, enabled}: UpdatedPolicyTagParams) => `${enabled ? 'habilitó' : 'deshabilitó'} la etiqueta "${tagName}" en la lista "${tagListName}"`, deleteTag: ({tagListName, tagName}: UpdatedPolicyTagParams) => `eliminó la etiqueta "${tagName}" de la lista "${tagListName}"`, updateTag: ({tagListName, newValue, tagName, updatedField, oldValue}: UpdatedPolicyTagFieldParams) => { if (oldValue) { - return `actualizó la etiqueta "${tagName}" en la lista "${tagListName}" cambiando el ${updatedField} de "${oldValue}" a "${newValue}"`; + return `actualizó la etiqueta "${tagName}" en la lista "${tagListName}" cambiando el ${updatedField} a "${newValue}" (previamente "${oldValue}")`; } return `actualizó la etiqueta "${tagName}" en la lista "${tagListName}" añadiendo un ${updatedField} de "${newValue}"`; }, - addedReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `agregó el Campo de Informe ${fieldType} "${fieldName}"`, + addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `añadió una nueva tasa de "${rateName}" para "${customUnitName}"`, + addedReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `añadió el campo de informe ${fieldType} "${fieldName}"`, updateReportFieldDefaultValue: ({defaultValue, fieldName}: UpdatedPolicyReportFieldDefaultValueParams) => - `actualizó el campo del informe "${fieldName}"; estableció el valor predeterminado como "${defaultValue}"`, + `estableció el valor predeterminado del campo de informe "${fieldName}" en "${defaultValue}"`, deleteReportField: ({fieldType, fieldName}: AddedOrDeletedPolicyReportFieldParams) => `eliminó el campo de informe ${fieldType} "${fieldName}"`, - addCustomUnitRate: ({customUnitName, rateName}: AddedPolicyCustomUnitRateParams) => `agregó una nueva tasa de "${rateName}" para "${customUnitName}"`, preventSelfApproval: ({oldValue, newValue}: UpdatedPolicyPreventSelfApprovalParams) => - `actualizó "Evitar la autoaprobación" de "${oldValue === 'true' ? 'Habilitado' : 'Deshabilitado'}" a "${newValue === 'true' ? 'Habilitado' : 'Deshabilitado'}"`, + `actualizó "Evitar la autoaprobación" a "${newValue === 'true' ? 'Habilitada' : 'Deshabilitada'}" (previamente "${oldValue === 'true' ? 'Habilitada' : 'Deshabilitada'}")`, updateMaxExpenseAmountNoReceipt: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => - `cambió el monto máximo de gasto requerido sin recibo de ${oldValue} a ${newValue}`, - updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `cambió el monto máximo de gasto para violaciones de ${oldValue} a ${newValue}`, + `cambió el monto máximo de gasto requerido sin recibo a ${newValue} (previamente ${oldValue})`, + updateMaxExpenseAmount: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => + `cambió el monto máximo de gasto para violaciones a ${newValue} (previamente ${oldValue})`, updateMaxExpenseAge: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => - `actualizó "Antigüedad Máxima de Gastos (días)" de "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}" a "${newValue}"`, - updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => `actualizó "Refacturar gastos a clientes" de "${oldValue}" a "${newValue}"`, - updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `cambió "Aplicar título predeterminado de informe" a ${value ? 'activado' : 'desactivado'}`, + `actualizó "Antigüedad máxima de gastos (días)" a "${newValue}" (previamente "${oldValue === 'false' ? CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE : oldValue}")`, + updateDefaultBillable: ({oldValue, newValue}: UpdatedPolicyFieldWithNewAndOldValueParams) => + `actualizó "Volver a facturar gastos a clientes" a "${newValue}" (previamente "${oldValue}")`, + updateDefaultTitleEnforced: ({value}: UpdatedPolicyFieldWithValueParam) => `cambió "Requerir título predeterminado de informe" a ${value ? 'activado' : 'desactivado'}`, updateWorkspaceDescription: ({newDescription, oldDescription}: UpdatedPolicyDescriptionParams) => !oldDescription - ? `estableció la descripción de este espacio de trabajo en "${newDescription}"` - : `actualizó la descripción de este espacio de trabajo de "${oldDescription}" a "${newDescription}"`, + ? `estableció la descripción de este espacio de trabajo como "${newDescription}"` + : `actualizó la descripción de este espacio de trabajo a "${newDescription}" (previamente "${oldDescription}")`, renamedWorkspaceNameAction: ({oldName, newName}: RenamedRoomActionParams) => `actualizó el nombre de este espacio de trabajo a "${newName}" (previamente "${oldName}")`, removedFromApprovalWorkflow: ({submittersNames}: RemovedFromApprovalWorkflowParams) => { let joinedNames = ''; @@ -4789,10 +4791,10 @@ const translations = { other: `te eliminó de los flujos de trabajo de aprobaciones y de los chats del espacio de trabajo de ${joinedNames}. Los informes enviados anteriormente seguirán estando disponibles para su aprobación en tu bandeja de entrada.`, }; }, - updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `actualizó la moneda predeterminada de ${oldCurrency} a ${newCurrency}`, + updatedWorkspaceCurrencyAction: ({oldCurrency, newCurrency}: UpdatedPolicyCurrencyParams) => `actualizó la moneda predeterminada a ${newCurrency} (previamente ${oldCurrency})`, updatedWorkspaceFrequencyAction: ({oldFrequency, newFrequency}: UpdatedPolicyFrequencyParams) => - `actualizó la frecuencia de generación automática de informes de "${oldFrequency}" a "${newFrequency}"`, - updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `Actualizó el Modo de Aprobación de "${oldValue}" a "${newValue}".`, + `actualizó la frecuencia de generación automática de informes a "${newFrequency}" (previamente "${oldFrequency}")`, + updateApprovalMode: ({newValue, oldValue}: ChangeFieldParams) => `actualizó el modo de aprobación a "${newValue}" (previamente "${oldValue}")`, upgradedWorkspace: 'mejoró este espacio de trabajo al plan Controlar', downgradedWorkspace: 'bajó de categoría este espacio de trabajo al plan Recopilar', }, From d14d97c29ca9be30f4328fff71b683631d722cfe Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 3 Feb 2025 13:21:34 +0530 Subject: [PATCH 35/38] fix typescript check fails. Signed-off-by: krishna2323 --- src/types/onyx/OriginalMessage.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 71340ebe0880..58f734378e65 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -270,11 +270,11 @@ type OriginalMessageChangeLog = { /** When was it last modified */ lastModified?: string; - /** New role of user */ - newValue?: string; + /** New role of user or new value of the category/tag field */ + newValue?: boolean | string; - /** Old role of user */ - oldValue?: string; + /** Old role of user or old value of the category/tag field */ + oldValue?: boolean | string; /** Name of connection */ connectionName?: AllConnectionName; @@ -312,12 +312,6 @@ type OriginalMessagePolicyChangeLog = { /** When was it last modified */ lastModified?: string; - /** New Value of the category/tag field */ - newValue?: boolean | string; - - /** Old Value of the category/tag field */ - oldValue?: boolean | string; - /** Old currency of the workspace */ oldCurrency?: string; @@ -398,6 +392,12 @@ type OriginalMessagePolicyChangeLog = { /** update type of a report field */ updateType?: string; + + /** New role of user or new value of the category/tag field */ + newValue?: boolean | string; + + /** Old role of user or old value of the category/tag field */ + oldValue?: boolean | string; }; /** Model of `join policy changelog` report action */ From 3ab861efe15d430628653166879904531bb88f6d Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Mon, 10 Feb 2025 16:35:44 +0530 Subject: [PATCH 36/38] prettier fix. Signed-off-by: krishna2323 --- src/libs/SidebarUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index c298015fc39c..eb92259339d0 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -31,9 +31,9 @@ import { getPolicyChangeLogDefaultBillableMessage, getPolicyChangeLogDefaultTitleEnforcedMessage, getPolicyChangeLogDeleteMemberMessage, + getPolicyChangeLogEmployeeLeftMessage, getPolicyChangeLogMaxExpenseAmountMessage, getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, - getPolicyChangeLogEmployeeLeftMessage, getRemovedConnectionMessage, getRenamedAction, getReportAction, From 3dafa170742533972aa9b44ffacbc103427981ab Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 12 Feb 2025 12:36:18 +0530 Subject: [PATCH 37/38] remove duplicate UpdateAutoReportingFrequency translation utils. Signed-off-by: krishna2323 --- src/languages/en.ts | 3 --- src/languages/es.ts | 3 --- src/languages/params.ts | 6 ------ src/libs/ReportActionsUtils.ts | 17 ----------------- .../report/ContextMenu/ContextMenuActions.tsx | 3 --- src/pages/home/report/PureReportActionItem.tsx | 3 --- src/types/onyx/OriginalMessage.ts | 6 ------ 7 files changed, 41 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 21accc45126b..82ab4e65e72f 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -189,7 +189,6 @@ import type { UpdatedPolicyTagFieldParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, - UpdateAutoReportingFrequencyParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -5148,8 +5147,6 @@ const translations = { leftWorkspace: ({nameOrEmail}: LeftWorkspaceParams) => `${nameOrEmail} left the workspace`, removeMember: ({email, role}: AddEmployeeParams) => `removed ${role === 'member' || role === 'user' ? 'member' : 'admin'} ${email}`, removedConnection: ({connectionName}: ConnectionNameParams) => `removed connection to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`, - updateAutoReportingFrequency: ({oldFrequency, newFrequency}: UpdateAutoReportingFrequencyParams) => - `updated the submission frequency to "${newFrequency}" (previously "${oldFrequency}")`, }, }, }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 6c0e69ddb3cf..a664a6b7797e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -188,7 +188,6 @@ import type { UpdatedPolicyTagFieldParams, UpdatedPolicyTagNameParams, UpdatedPolicyTagParams, - UpdateAutoReportingFrequencyParams, UpdatedTheDistanceMerchantParams, UpdatedTheRequestParams, UpdateRoleParams, @@ -5203,8 +5202,6 @@ const translations = { leftWorkspace: ({nameOrEmail}: LeftWorkspaceParams) => `${nameOrEmail} salió del espacio de trabajo`, removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role === 'miembro' || role === 'user' ? 'miembro' : 'administrador'} ${email}`, removedConnection: ({connectionName}: ConnectionNameParams) => `eliminó la conexión a ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}`, - updateAutoReportingFrequency: ({oldFrequency, newFrequency}: UpdateAutoReportingFrequencyParams) => - `actualizó la frecuencia de envíos a "${newFrequency}" (previamente "${oldFrequency}")`, }, }, }, diff --git a/src/languages/params.ts b/src/languages/params.ts index cd0844661b27..ae9c277a97e4 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -377,11 +377,6 @@ type ConnectionNameParams = { connectionName: AllConnectionName; }; -type UpdateAutoReportingFrequencyParams = { - oldFrequency: string; - newFrequency: string; -}; - type LastSyncDateParams = { connectionName: string; formattedDate: string; @@ -843,7 +838,6 @@ export type { UpdateRoleParams, LeftWorkspaceParams, RemoveMemberParams, - UpdateAutoReportingFrequencyParams, DateParams, FiltersAmountBetweenParams, StatementPageTitleParams, diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 531b377269a8..16abd4a25cdd 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -2071,22 +2071,6 @@ function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry, -): reportAction is ReportAction { - return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY); -} - -function getPolicyChangeLogUpdateAutoReportingFrequencyMessage(reportAction: OnyxInputOrEntry): string { - if (!isPolicyChangeLogUpdateAutoReportingFrequencyMessage(reportAction)) { - return ''; - } - const originalMessage = getOriginalMessage(reportAction); - const oldFrequency = translateLocal(`workspace.common.frequency.${originalMessage?.oldFrequency}` as TranslationPaths); - const newFrequency = translateLocal(`workspace.common.frequency.${originalMessage?.newFrequency}` as TranslationPaths); - return translateLocal('report.actions.type.updateAutoReportingFrequency', {oldFrequency, newFrequency}); -} - function getRemovedConnectionMessage(reportAction: OnyxEntry): string { if (!isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { return ''; @@ -2320,7 +2304,6 @@ export { getPolicyChangeLogAddEmployeeMessage, getPolicyChangeLogChangeRoleMessage, getPolicyChangeLogDeleteMemberMessage, - getPolicyChangeLogUpdateAutoReportingFrequencyMessage, getPolicyChangeLogEmployeeLeftMessage, getRenamedAction, isCardIssuedAction, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index e0cff608558a..c71bcf45e828 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -36,7 +36,6 @@ import { getPolicyChangeLogDeleteMemberMessage, getPolicyChangeLogMaxExpenseAmountMessage, getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, - getPolicyChangeLogUpdateAutoReportingFrequencyMessage, getRemovedConnectionMessage, getRenamedAction, getReportActionMessageText, @@ -594,8 +593,6 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(getPolicyChangeLogChangeRoleMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { setClipboardMessage(getPolicyChangeLogDeleteMemberMessage(reportAction)); - } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - setClipboardMessage(getPolicyChangeLogUpdateAutoReportingFrequencyMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) { setClipboardMessage(getDeletedTransactionMessage(reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 0064431f11aa..413e77d8fb39 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -60,7 +60,6 @@ import { getPolicyChangeLogDeleteMemberMessage, getPolicyChangeLogMaxExpenseAmountMessage, getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, - getPolicyChangeLogUpdateAutoReportingFrequencyMessage, getRemovedConnectionMessage, getRemovedFromApprovalChainMessage, getRenamedAction, @@ -923,8 +922,6 @@ function PureReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { children = ; - } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { children = ; } else if ( diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 204842ce9112..58f734378e65 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -398,12 +398,6 @@ type OriginalMessagePolicyChangeLog = { /** Old role of user or old value of the category/tag field */ oldValue?: boolean | string; - - /** Old auto-reporting frequency */ - oldFrequency?: string; - - /** New auto-reporting frequency */ - newFrequency?: string; }; /** Model of `join policy changelog` report action */ From 4622f94a8162252efab6df5be3559dbb99968e0a Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 12 Feb 2025 12:39:29 +0530 Subject: [PATCH 38/38] remove duplicate UpdateAutoReportingFrequency translation utils. Signed-off-by: krishna2323 --- src/libs/SidebarUtils.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index c4e8a4d4222c..eb92259339d0 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -34,7 +34,6 @@ import { getPolicyChangeLogEmployeeLeftMessage, getPolicyChangeLogMaxExpenseAmountMessage, getPolicyChangeLogMaxExpesnseAmountNoReceiptMessage, - getPolicyChangeLogUpdateAutoReportingFrequencyMessage, getRemovedConnectionMessage, getRenamedAction, getReportAction, @@ -606,8 +605,6 @@ function getOptionData({ result.alternateText = getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { result.alternateText = getRemovedConnectionMessage(lastAction); - } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - result.alternateText = getPolicyChangeLogUpdateAutoReportingFrequencyMessage(lastAction); } else { result.alternateText = lastMessageTextFromReport.length > 0