From 3de0f40d32b9c0aabb56de660dbed0130e6a9709 Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 18 Jul 2024 21:50:02 +0700 Subject: [PATCH 1/6] format message for integration action --- src/libs/ReportActionsUtils.ts | 5 +++++ src/libs/ReportUtils.ts | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index add379d462b0..54888ed126c2 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -179,6 +179,10 @@ function isTripPreview(reportAction: OnyxInputOrEntry): reportActi return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW); } +function isIntergrationAction(reportAction: OnyxInputOrEntry): reportAction is ReportAction { + return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE); +} + function isActionOfType( action: OnyxInputOrEntry, ...actionNames: T @@ -1626,6 +1630,7 @@ export { getExportIntegrationActionFragments, getExportIntegrationLastMessageText, getExportIntegrationMessageHTML, + isIntergrationAction, }; export type {LastVisibleMessage}; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ace8f547b75c..06607f512953 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3378,6 +3378,13 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa return formatReportLastMessageText(formattedName); } + if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isIntergrationAction(parentReportAction)) { + const {originalMessage, actionName} = parentReportAction; + const {result, label} = originalMessage; + const errorMessage = result?.messages?.join(', ') ?? ''; + return Localize.translateLocal('report.actions.type.integrationsMessage', errorMessage, label); + } + if (ReportActionsUtils.getReportActionMessage(parentReportAction)?.isDeletedParentAction) { return Localize.translateLocal('parentReportAction.deletedMessage'); } From 85b62d89a2a974de08a32929311af367b36ebf3d Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 18 Jul 2024 22:06:49 +0700 Subject: [PATCH 2/6] fix lint --- src/libs/ReportUtils.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 06607f512953..f08fbd86ed0d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3379,10 +3379,9 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa } if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isIntergrationAction(parentReportAction)) { - const {originalMessage, actionName} = parentReportAction; - const {result, label} = originalMessage; - const errorMessage = result?.messages?.join(', ') ?? ''; - return Localize.translateLocal('report.actions.type.integrationsMessage', errorMessage, label); + const originalMessage = ReportActionsUtils.getOriginalMessage(parentReportAction) + const errorMessage = originalMessage?.result?.messages?.join(', ') ?? ''; + return Localize.translateLocal('report.actions.type.integrationsMessage', errorMessage, originalMessage?.label); } if (ReportActionsUtils.getReportActionMessage(parentReportAction)?.isDeletedParentAction) { From 9aaad0343fbed642d0ca47b2e7ed0435768f1c0b Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 18 Jul 2024 23:01:43 +0700 Subject: [PATCH 3/6] update report name for all oldDot action --- src/libs/ReportUtils.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f08fbd86ed0d..f30920d9f78c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -46,7 +46,7 @@ import type {OriginalMessageChangeLog, PaymentMethodType} from '@src/types/onyx/ import type {Status} from '@src/types/onyx/PersonalDetails'; import type {ConnectionName} from '@src/types/onyx/Policy'; import type {NotificationPreference, Participants, PendingChatMember, Participant as ReportParticipant} from '@src/types/onyx/Report'; -import type {Message, ReportActions} from '@src/types/onyx/ReportAction'; +import type {Message, OldDotReportAction, ReportActions} from '@src/types/onyx/ReportAction'; import type {Comment, Receipt, TransactionChanges, WaypointCollection} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type IconAsset from '@src/types/utils/IconAsset'; @@ -3378,10 +3378,8 @@ function getReportName(report: OnyxEntry, policy?: OnyxEntry, pa return formatReportLastMessageText(formattedName); } - if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isIntergrationAction(parentReportAction)) { - const originalMessage = ReportActionsUtils.getOriginalMessage(parentReportAction) - const errorMessage = originalMessage?.result?.messages?.join(', ') ?? ''; - return Localize.translateLocal('report.actions.type.integrationsMessage', errorMessage, originalMessage?.label); + if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isOldDotReportAction(parentReportAction)) { + return ReportActionsUtils.getMessageOfOldDotReportAction(parentReportAction); } if (ReportActionsUtils.getReportActionMessage(parentReportAction)?.isDeletedParentAction) { From 09d71bc71be0d7d7973957befbd9cb5690d845bd Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 18 Jul 2024 23:03:09 +0700 Subject: [PATCH 4/6] remove reduntdant code --- src/libs/ReportActionsUtils.ts | 5 ----- src/libs/ReportUtils.ts | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 54888ed126c2..add379d462b0 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -179,10 +179,6 @@ function isTripPreview(reportAction: OnyxInputOrEntry): reportActi return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW); } -function isIntergrationAction(reportAction: OnyxInputOrEntry): reportAction is ReportAction { - return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE); -} - function isActionOfType( action: OnyxInputOrEntry, ...actionNames: T @@ -1630,7 +1626,6 @@ export { getExportIntegrationActionFragments, getExportIntegrationLastMessageText, getExportIntegrationMessageHTML, - isIntergrationAction, }; export type {LastVisibleMessage}; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f30920d9f78c..624bbc6acd92 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -46,7 +46,7 @@ import type {OriginalMessageChangeLog, PaymentMethodType} from '@src/types/onyx/ import type {Status} from '@src/types/onyx/PersonalDetails'; import type {ConnectionName} from '@src/types/onyx/Policy'; import type {NotificationPreference, Participants, PendingChatMember, Participant as ReportParticipant} from '@src/types/onyx/Report'; -import type {Message, OldDotReportAction, ReportActions} from '@src/types/onyx/ReportAction'; +import type {Message, ReportActions} from '@src/types/onyx/ReportAction'; import type {Comment, Receipt, TransactionChanges, WaypointCollection} from '@src/types/onyx/Transaction'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type IconAsset from '@src/types/utils/IconAsset'; From cd979db2921eeace9114528c25fe47938910cafb Mon Sep 17 00:00:00 2001 From: Hans Date: Fri, 19 Jul 2024 23:27:27 +0700 Subject: [PATCH 5/6] polish export_to_integration message --- src/libs/OptionsListUtils.ts | 2 -- src/libs/ReportActionsUtils.ts | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index c552c5521219..7d45fd7ea133 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -737,8 +737,6 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(reportID); } else if (ReportActionUtils.isActionableAddPaymentCard(lastReportAction)) { lastMessageTextFromReport = ReportActionUtils.getReportActionMessageText(lastReportAction); - } else if (lastReportAction?.actionName === 'EXPORTINTEGRATION') { - lastMessageTextFromReport = ReportActionUtils.getExportIntegrationLastMessageText(lastReportAction); } else if (lastReportAction?.actionName && ReportActionUtils.isOldDotReportAction(lastReportAction)) { lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction); } diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index add379d462b0..c93021fb0155 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1201,6 +1201,7 @@ function isOldDotReportAction(action: ReportAction | OldDotReportAction) { CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_QUICK_BOOKS, CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED, CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP, + CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION, ].some((oldDotActionName) => oldDotActionName === action.actionName); } @@ -1274,6 +1275,8 @@ function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldD return Localize.translateLocal('report.actions.type.unshare', {to: originalMessage.to}); case CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL: return Localize.translateLocal('report.actions.type.takeControl'); + case CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION: + return getExportIntegrationLastMessageText(oldDotAction as ReportAction); default: return ''; } From 6fab3428fa758fdbdd7837fae3827e41fdecf59d Mon Sep 17 00:00:00 2001 From: Hans Date: Sun, 21 Jul 2024 10:18:38 +0700 Subject: [PATCH 6/6] update export to integration format message --- src/libs/OptionsListUtils.ts | 2 ++ src/libs/ReportActionsUtils.ts | 3 --- src/libs/ReportUtils.ts | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 7d45fd7ea133..c552c5521219 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -737,6 +737,8 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(reportID); } else if (ReportActionUtils.isActionableAddPaymentCard(lastReportAction)) { lastMessageTextFromReport = ReportActionUtils.getReportActionMessageText(lastReportAction); + } else if (lastReportAction?.actionName === 'EXPORTINTEGRATION') { + lastMessageTextFromReport = ReportActionUtils.getExportIntegrationLastMessageText(lastReportAction); } else if (lastReportAction?.actionName && ReportActionUtils.isOldDotReportAction(lastReportAction)) { lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction); } diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index c93021fb0155..add379d462b0 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1201,7 +1201,6 @@ function isOldDotReportAction(action: ReportAction | OldDotReportAction) { CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_QUICK_BOOKS, CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_REQUESTED, CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_SETUP, - CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION, ].some((oldDotActionName) => oldDotActionName === action.actionName); } @@ -1275,8 +1274,6 @@ function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldD return Localize.translateLocal('report.actions.type.unshare', {to: originalMessage.to}); case CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL: return Localize.translateLocal('report.actions.type.takeControl'); - case CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION: - return getExportIntegrationLastMessageText(oldDotAction as ReportAction); default: return ''; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 624bbc6acd92..abc503129748 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3327,6 +3327,11 @@ function getReportActionMessage(reportAction: OnyxEntry, reportID? if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { return Localize.translateLocal('iou.heldExpense'); } + + if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) { + return ReportActionsUtils.getExportIntegrationLastMessageText(reportAction); + } + if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { return Localize.translateLocal('iou.unheldExpense'); }