From 50e43779cf17a2ddba53589fc0bce9ef8b5ac6cd Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 9 Jan 2025 15:04:23 +0700 Subject: [PATCH 1/6] fix: System message is shown in English --- src/languages/en.ts | 2 ++ src/languages/es.ts | 2 ++ src/libs/OptionsListUtils.ts | 4 ++++ src/libs/ReportUtils.ts | 16 ++++++++++++++++ .../report/ContextMenu/ContextMenuActions.tsx | 6 ++++++ src/pages/home/report/PureReportActionItem.tsx | 4 ++++ 6 files changed, 34 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1ff4ef4c0ae4..d12a82d5f94c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4604,6 +4604,8 @@ const translations = { other: `removed you from ${joinedNames}'s approval workflows and workspace chats. Previously submitted reports will remain available for approval in your Inbox.`, }; }, + upgradedWorkspace: 'upgraded this workspace to the Control plan', + downgradedWorkspace: 'downgraded this workspace to the Collect plan', }, roomMembersPage: { memberNotFound: 'Member not found.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 92e94446aa48..d800c22e7e12 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4652,6 +4652,8 @@ 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.`, }; }, + upgradedWorkspace: 'mejoró este espacio de trabajo al plan Controlar', + downgradedWorkspace: 'bajó este espacio de trabajo al plan Recopilar', }, roomMembersPage: { memberNotFound: 'Miembro no encontrado.', diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 4d1988a53bde..fc01e42394dd 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -599,6 +599,10 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails } } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { lastMessageTextFromReport = ReportUtils.getRejectedReportMessage(); + } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + lastMessageTextFromReport = ReportUtils.getUpgradeWorkspaceMessage(); + } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { + lastMessageTextFromReport = ReportUtils.getDowngradeWorkspaceMessage(); } else if (ReportActionUtils.isActionableAddPaymentCard(lastReportAction)) { lastMessageTextFromReport = ReportActionUtils.getReportActionMessageText(lastReportAction); } else if (lastReportAction?.actionName === 'EXPORTINTEGRATION') { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8a5ae8b1d102..4cd431d690e8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4063,6 +4063,12 @@ function getReportName( if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { return getRejectedReportMessage(); } + if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + return getUpgradeWorkspaceMessage(); + } + if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { + return getDowngradeWorkspaceMessage(); + } if (ReportActionsUtils.isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.APPROVED)) { const {automaticAction} = ReportActionsUtils.getOriginalMessage(parentReportAction) ?? {}; if (automaticAction) { @@ -4954,6 +4960,14 @@ function getRejectedReportMessage() { return Localize.translateLocal('iou.rejectedThisReport'); } +function getUpgradeWorkspaceMessage() { + return Localize.translateLocal('workspaceActions.upgradedWorkspace'); +} + +function getDowngradeWorkspaceMessage() { + return Localize.translateLocal('workspaceActions.downgradedWorkspace'); +} + 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); @@ -8790,6 +8804,8 @@ export { getIOUForwardedMessage, getRejectedReportMessage, getWorkspaceNameUpdatedMessage, + getUpgradeWorkspaceMessage, + getDowngradeWorkspaceMessage, getReportAutomaticallySubmittedMessage, getIOUSubmittedMessage, getIcons, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index b8cdde2ecff3..96fd107ce3e9 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -451,6 +451,12 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { const displayMessage = ReportUtils.getRejectedReportMessage(); Clipboard.setString(displayMessage); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { + const displayMessage = ReportUtils.getUpgradeWorkspaceMessage(); + Clipboard.setString(displayMessage); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE) { + const displayMessage = ReportUtils.getDowngradeWorkspaceMessage(); + Clipboard.setString(displayMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { Clipboard.setString(Localize.translateLocal('iou.heldExpense')); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index dd44558f83bf..0a80382552df 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -806,6 +806,10 @@ function PureReportActionItem({ } } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { 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.HOLD) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) { From 79906f09d20b2bdb0e6023f5521f1d361c9877c1 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 10 Jan 2025 00:09:37 +0700 Subject: [PATCH 2/6] fix lint --- src/libs/actions/Report.ts | 4 ++-- .../home/report/ContextMenu/ContextMenuActions.tsx | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 1e157b983483..559bcb0a6dec 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1363,8 +1363,8 @@ function readNewestAction(reportID: string | undefined, shouldResetUnreadMarker /** * Sets the last read time on a report */ -function markCommentAsUnread(reportID: string, reportActionCreated: string) { - if (reportID === '-1') { +function markCommentAsUnread(reportID?: string, reportActionCreated?: string) { + if (reportID === '-1' || !reportID || !reportActionCreated) { Log.warn('7339cd6c-3263-4f89-98e5-730f0be15784 Invalid report passed to MarkCommentAsUnread. Not calling the API because it wil fail.'); return; } diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 96fd107ce3e9..6c700dc1ace4 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -193,11 +193,11 @@ const ContextMenuActions: ContextMenuAction[] = [ // is false, so we need to pass true here to override this condition. ReportActionComposeFocusManager.focus(true); }); - Report.navigateToAndOpenChildReport(reportAction?.childReportID ?? '-1', reportAction, originalReportID); + Report.navigateToAndOpenChildReport(reportAction?.childReportID, reportAction, originalReportID); }); return; } - Report.navigateToAndOpenChildReport(reportAction?.childReportID ?? '-1', reportAction, originalReportID); + Report.navigateToAndOpenChildReport(reportAction?.childReportID, reportAction, originalReportID); }, getDescription: () => {}, }, @@ -208,7 +208,7 @@ const ContextMenuActions: ContextMenuAction[] = [ successIcon: Expensicons.Checkmark, shouldShow: ({type, isUnreadChat}) => type === CONST.CONTEXT_MENU_TYPES.REPORT_ACTION || (type === CONST.CONTEXT_MENU_TYPES.REPORT && !isUnreadChat), onPress: (closePopover, {reportAction, reportID}) => { - const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction) ?? '-1'; + const originalReportID = ReportUtils.getOriginalReportID(reportID, reportAction); Report.markCommentAsUnread(originalReportID, reportAction?.created); if (closePopover) { hideContextMenu(true, ReportActionComposeFocusManager.focus); @@ -239,7 +239,7 @@ const ContextMenuActions: ContextMenuAction[] = [ onPress: (closePopover, {reportID, reportAction, draftMessage}) => { if (ReportActionsUtils.isMoneyRequestAction(reportAction)) { hideContextMenu(false); - const childReportID = reportAction?.childReportID ?? '-1'; + const childReportID = `${reportAction?.childReportID ?? CONST.DEFAULT_NUMBER_ID}`; Report.openReport(childReportID); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID)); return; @@ -324,13 +324,13 @@ const ContextMenuActions: ContextMenuAction[] = [ if (closePopover) { hideContextMenu(false, () => { ReportActionComposeFocusManager.focus(); - Report.toggleSubscribeToChildReport(reportAction?.childReportID ?? '-1', reportAction, originalReportID, childReportNotificationPreference); + Report.toggleSubscribeToChildReport(reportAction?.childReportID, reportAction, originalReportID, childReportNotificationPreference); }); return; } ReportActionComposeFocusManager.focus(); - Report.toggleSubscribeToChildReport(reportAction?.childReportID ?? '-1', reportAction, originalReportID, childReportNotificationPreference); + Report.toggleSubscribeToChildReport(reportAction?.childReportID, reportAction, originalReportID, childReportNotificationPreference); }, getDescription: () => {}, }, From 5921e7c40068c8e4e339bb24d844c20be56bade6 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 13 Jan 2025 11:35:59 +0700 Subject: [PATCH 3/6] fix logic --- src/libs/actions/Report.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 559bcb0a6dec..a0138fb384cf 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1364,7 +1364,7 @@ function readNewestAction(reportID: string | undefined, shouldResetUnreadMarker * Sets the last read time on a report */ function markCommentAsUnread(reportID?: string, reportActionCreated?: string) { - if (reportID === '-1' || !reportID || !reportActionCreated) { + if (reportID === '-1' || !reportID) { Log.warn('7339cd6c-3263-4f89-98e5-730f0be15784 Invalid report passed to MarkCommentAsUnread. Not calling the API because it wil fail.'); return; } @@ -1386,7 +1386,7 @@ function markCommentAsUnread(reportID?: string, reportActionCreated?: string) { // If no action created date is provided, use the last action's from other user const actionCreationTime = - reportActionCreated || (latestReportActionFromOtherUsers?.created ?? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.lastVisibleActionCreated ?? DateUtils.getDBTime(0)); + reportActionCreated ?? latestReportActionFromOtherUsers?.created ?? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.lastVisibleActionCreated ?? DateUtils.getDBTime(0); // We subtract 1 millisecond so that the lastReadTime is updated to just before a given reportAction's created date // For example, if we want to mark a report action with ID 100 and created date '2014-04-01 16:07:02.999' unread, we set the lastReadTime to '2014-04-01 16:07:02.998' From ca703c014b628019d99fc250ff5817a72a301734 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 13 Jan 2025 16:00:11 +0700 Subject: [PATCH 4/6] fix: translation and lint --- src/languages/es.ts | 2 +- src/libs/actions/Report.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index e791fb06e0f0..fcdcc0beaaec 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4656,7 +4656,7 @@ const translations = { }; }, upgradedWorkspace: 'mejoró este espacio de trabajo al plan Controlar', - downgradedWorkspace: 'bajó este espacio de trabajo al plan Recopilar', + downgradedWorkspace: 'bajó de categoría este espacio de trabajo al plan Recopilar', }, roomMembersPage: { memberNotFound: 'Miembro no encontrado.', diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index a0138fb384cf..48181e2181c3 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1363,8 +1363,8 @@ function readNewestAction(reportID: string | undefined, shouldResetUnreadMarker /** * Sets the last read time on a report */ -function markCommentAsUnread(reportID?: string, reportActionCreated?: string) { - if (reportID === '-1' || !reportID) { +function markCommentAsUnread(reportID: string | undefined, reportActionCreated: string | undefined) { + if (!reportID) { Log.warn('7339cd6c-3263-4f89-98e5-730f0be15784 Invalid report passed to MarkCommentAsUnread. Not calling the API because it wil fail.'); return; } @@ -1386,7 +1386,8 @@ function markCommentAsUnread(reportID?: string, reportActionCreated?: string) { // If no action created date is provided, use the last action's from other user const actionCreationTime = - reportActionCreated ?? latestReportActionFromOtherUsers?.created ?? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.lastVisibleActionCreated ?? DateUtils.getDBTime(0); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + reportActionCreated || latestReportActionFromOtherUsers?.created ?? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.lastVisibleActionCreated ?? DateUtils.getDBTime(0); // We subtract 1 millisecond so that the lastReadTime is updated to just before a given reportAction's created date // For example, if we want to mark a report action with ID 100 and created date '2014-04-01 16:07:02.999' unread, we set the lastReadTime to '2014-04-01 16:07:02.998' From 1d94320cab5aa5c0dbe18d82b97aaed70fd2c7af Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 13 Jan 2025 16:09:03 +0700 Subject: [PATCH 5/6] fix lint --- src/libs/actions/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 48181e2181c3..b729dbe89c90 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1387,7 +1387,7 @@ function markCommentAsUnread(reportID: string | undefined, reportActionCreated: // If no action created date is provided, use the last action's from other user const actionCreationTime = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - reportActionCreated || latestReportActionFromOtherUsers?.created ?? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.lastVisibleActionCreated ?? DateUtils.getDBTime(0); + reportActionCreated || (latestReportActionFromOtherUsers?.created ?? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.lastVisibleActionCreated ?? DateUtils.getDBTime(0)); // We subtract 1 millisecond so that the lastReadTime is updated to just before a given reportAction's created date // For example, if we want to mark a report action with ID 100 and created date '2014-04-01 16:07:02.999' unread, we set the lastReadTime to '2014-04-01 16:07:02.998' From caf7cfe7cfa6e7baac77d9058494bb782563c280 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 13 Jan 2025 16:12:55 +0700 Subject: [PATCH 6/6] fix lint --- src/libs/actions/Report.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index b729dbe89c90..bea7a0e82b48 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1363,7 +1363,7 @@ function readNewestAction(reportID: string | undefined, shouldResetUnreadMarker /** * Sets the last read time on a report */ -function markCommentAsUnread(reportID: string | undefined, reportActionCreated: string | undefined) { +function markCommentAsUnread(reportID: string | undefined, reportActionCreated: string) { if (!reportID) { Log.warn('7339cd6c-3263-4f89-98e5-730f0be15784 Invalid report passed to MarkCommentAsUnread. Not calling the API because it wil fail.'); return; @@ -1386,7 +1386,6 @@ function markCommentAsUnread(reportID: string | undefined, reportActionCreated: // If no action created date is provided, use the last action's from other user const actionCreationTime = - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing reportActionCreated || (latestReportActionFromOtherUsers?.created ?? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]?.lastVisibleActionCreated ?? DateUtils.getDBTime(0)); // We subtract 1 millisecond so that the lastReadTime is updated to just before a given reportAction's created date