Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ const CONST = {
DELETED_TRANSACTION: 'DELETEDTRANSACTION',
DISMISSED_VIOLATION: 'DISMISSEDVIOLATION',
DONATION: 'DONATION', // Deprecated OldDot Action
DYNAMIC_EXTERNAL_WORKFLOW_ROUTED: 'DYNAMICEXTERNALWORKFLOWROUTED',
EXPENSIFY_CARD_SYSTEM_MESSAGE: 'EXPENSIFYCARDSYSTEMMESSAGE',
EXPORTED_TO_CSV: 'EXPORTCSV', // OldDot Action
EXPORTED_TO_INTEGRATION: 'EXPORTINTEGRATION', // OldDot Action
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useOriginalReportID.ts
Comment thread
bernhardoj marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useMemo} from 'react';
import {getAllNonDeletedTransactions} from '@libs/MoneyRequestReportUtils';
import {getOneTransactionThreadReportID} from '@libs/ReportActionsUtils';
import {getOneTransactionThreadReportID, withDEWRoutedActionsObject} from '@libs/ReportActionsUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {OnyxInputOrEntry, ReportAction} from '@src/types/onyx';
Expand All @@ -21,7 +21,7 @@ import useTransactionsAndViolationsForReport from './useTransactionsAndViolation
*
*/
function useOriginalReportID(reportID: string | undefined, reportAction: OnyxInputOrEntry<Pick<ReportAction, 'reportActionID' | 'childReportID'>>): string | undefined {
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {canBeMissing: true});
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {canBeMissing: true, selector: withDEWRoutedActionsObject});
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true});
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`, {canBeMissing: true});
const {isOffline} = useNetwork();
Expand Down
2 changes: 2 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1513,6 +1514,7 @@ const translations: TranslationDeepObject<typeof en> = {
splitDates: 'Datumsangaben aufteilen',
splitDateRange: ({startDate, endDate, count}: SplitDateRangeParams) => `${startDate} bis ${endDate} (${count} Tage)`,
splitByDate: 'Nach Datum aufteilen',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `bericht aufgrund eines benutzerdefinierten Genehmigungsworkflows an ${to} weitergeleitet`,
},
transactionMerge: {
listPage: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1484,6 +1485,7 @@ const translations = {
},
},
chooseWorkspace: 'Choose a workspace',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `report routed to ${to} due to custom approval workflow`,
},
transactionMerge: {
listPage: {
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {CONST as COMMON_CONST} from 'expensify-common';
import dedent from '@libs/StringUtils/dedent';
import CONST from '@src/CONST';
import type en from './en';
import type {HarvestCreatedExpenseReportParams, SplitDateRangeParams, ViolationsRterParams} from './params';
import type {HarvestCreatedExpenseReportParams, RoutedDueToDEWParams, SplitDateRangeParams, ViolationsRterParams} from './params';
import type {TranslationDeepObject} from './types';

/* eslint-disable max-len */
Expand Down Expand Up @@ -1186,6 +1186,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'Elige un espacio de trabajo',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `informe enviado a ${to} debido a un flujo de aprobación personalizado`,
},
transactionMerge: {
listPage: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1515,6 +1516,7 @@ const translations: TranslationDeepObject<typeof en> = {
splitDates: 'Diviser les dates',
splitDateRange: ({startDate, endDate, count}: SplitDateRangeParams) => `Du ${startDate} au ${endDate} (${count} jours)`,
splitByDate: 'Scinder par date',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `rapport acheminé vers ${to} en raison d'un workflow d'approbation personnalisé`,
},
transactionMerge: {
listPage: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1508,6 +1509,7 @@ const translations: TranslationDeepObject<typeof en> = {
splitDates: 'Dividi date',
splitDateRange: ({startDate, endDate, count}: SplitDateRangeParams) => `${startDate} a ${endDate} (${count} giorni)`,
splitByDate: 'Dividi per data',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `rapporto inoltrato a ${to} a causa del flusso di lavoro di approvazione personalizzato`,
},
transactionMerge: {
listPage: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1508,6 +1509,7 @@ const translations: TranslationDeepObject<typeof en> = {
splitDates: '日付を分割',
splitDateRange: ({startDate, endDate, count}: SplitDateRangeParams) => `${startDate} から ${endDate} まで(${count} 日間)`,
splitByDate: '日付で分割',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `カスタム承認ワークフローにより、${to} 宛にルーティングされたレポート`,
},
transactionMerge: {
listPage: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1507,6 +1508,7 @@ const translations: TranslationDeepObject<typeof en> = {
splitDates: 'Datums splitsen',
splitDateRange: ({startDate, endDate, count}: SplitDateRangeParams) => `${startDate} tot ${endDate} (${count} dagen)`,
splitByDate: 'Splitsen op datum',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `rapport doorgestuurd naar ${to} vanwege aangepaste goedkeuringsworkflow`,
},
transactionMerge: {
listPage: {
Expand Down
5 changes: 5 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,10 @@ type FocusModeUpdateParams = {
priorityModePageUrl: string;
};

type RoutedDueToDEWParams = {
to: string;
};

export type {
SettlementAccountReconciliationParams,
ToggleImportTitleParams,
Expand Down Expand Up @@ -1022,6 +1026,7 @@ export type {
NextStepParams,
ReportFieldParams,
FocusModeUpdateParams,
RoutedDueToDEWParams,
UpdatedPolicyCustomUnitRateIndexParams,
UpdatedPolicyCustomUnitRateEnabledParams,
};
2 changes: 2 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1505,6 +1506,7 @@ const translations: TranslationDeepObject<typeof en> = {
splitDates: 'Podziel daty',
splitDateRange: ({startDate, endDate, count}: SplitDateRangeParams) => `${startDate} do ${endDate} (${count} dni)`,
splitByDate: 'Podziel według daty',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `raport przekazany do ${to} z powodu niestandardowego procesu zatwierdzania`,
},
transactionMerge: {
listPage: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1505,6 +1506,7 @@ const translations: TranslationDeepObject<typeof en> = {
splitDates: 'Dividir datas',
splitDateRange: ({startDate, endDate, count}: SplitDateRangeParams) => `${startDate} a ${endDate} (${count} dias)`,
splitByDate: 'Dividir por data',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `relatório encaminhado para ${to} devido ao fluxo de trabalho de aprovação personalizado`,
},
transactionMerge: {
listPage: {
Expand Down
2 changes: 2 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import type {
RoleNamesParams,
RoomNameReservedErrorParams,
RoomRenamedToParams,
RoutedDueToDEWParams,
RulesEnableWorkflowsParams,
SecondaryLoginParams,
SetTheDistanceMerchantParams,
Expand Down Expand Up @@ -1482,6 +1483,7 @@ const translations: TranslationDeepObject<typeof en> = {
splitDates: '拆分日期',
splitDateRange: ({startDate, endDate, count}: SplitDateRangeParams) => `${startDate} 至 ${endDate}(${count} 天)`,
splitByDate: '按日期拆分',
routedDueToDEW: ({to}: RoutedDueToDEWParams) => `报告因自定义审批工作流而转发至 ${to}`,
},
transactionMerge: {
listPage: {
Expand Down
7 changes: 6 additions & 1 deletion src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
getActionableMentionWhisperMessage,
getChangedApproverActionMessage,
getCombinedReportActions,
getDynamicExternalWorkflowRoutedMessage,
getExportIntegrationLastMessageText,
getIOUReportIDFromReportActionPreview,
getJoinRequestMessage,
Expand Down Expand Up @@ -81,6 +82,7 @@
isUnapprovedAction,
isWhisperAction,
shouldReportActionBeVisible,
withDEWRoutedActionsArray,
} from '@libs/ReportActionsUtils';
import {computeReportName} from '@libs/ReportNameUtils';
import type {OptionData} from '@libs/ReportUtils';
Expand Down Expand Up @@ -188,7 +190,7 @@
*/
let currentUserLogin: string | undefined;
let currentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 193 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserLogin = value?.email;
Expand All @@ -197,19 +199,19 @@
});

let loginList: OnyxEntry<Login>;
Onyx.connect({

Check warning on line 202 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.LOGIN_LIST,
callback: (value) => (loginList = isEmptyObject(value) ? {} : value),
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 208 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = isEmptyObject(value) ? {} : value),
});

const policies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 214 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
callback: (policy, key) => {
if (!policy || !key || !policy.name) {
Expand All @@ -221,14 +223,14 @@
});

let allPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 226 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (val) => (allPolicies = val),
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 233 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -237,7 +239,7 @@
});

let allReportNameValuePairs: OnyxCollection<ReportNameValuePairs>;
Onyx.connect({

Check warning on line 242 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -249,7 +251,7 @@
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const lastVisibleReportActions: ReportActions = {};
Onyx.connect({

Check warning on line 254 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -267,7 +269,7 @@
}

const reportActionsArray = Object.values(reportActions[1] ?? {});
let sortedReportActions = getSortedReportActions(reportActionsArray, true);
let sortedReportActions = getSortedReportActions(withDEWRoutedActionsArray(reportActionsArray), true);
allSortedReportActions[reportID] = sortedReportActions;
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`];
Expand Down Expand Up @@ -311,7 +313,7 @@
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 316 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});
Expand Down Expand Up @@ -785,6 +787,9 @@
lastMessageTextFromReport = Parser.htmlToText(getUnreportedTransactionMessage(lastReportAction));
} else if (isActionableMentionWhisper(lastReportAction)) {
lastMessageTextFromReport = Parser.htmlToText(getActionableMentionWhisperMessage(lastReportAction));
} else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
lastMessageTextFromReport = getDynamicExternalWorkflowRoutedMessage(lastReportAction, translateLocal);
}

// we do not want to show report closed in LHN for non archived report so use getReportLastMessage as fallback instead of lastMessageText from report
Expand Down
66 changes: 65 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import {isCardPendingActivate} from './CardUtils';
import {getDecodedCategoryName} from './CategoryUtils';
import {convertAmountToDisplayString, convertToDisplayString, convertToShortDisplayString} from './CurrencyUtils';
import DateUtils from './DateUtils';
import {getEnvironmentURL, getOldDotEnvironmentURL} from './Environment/Environment';
import getBase62ReportID from './getBase62ReportID';
import {isReportMessageAttachment} from './isReportMessageAttachment';
Expand Down Expand Up @@ -59,7 +60,7 @@
type MemberChangeMessageElement = MessageTextElement | MemberChangeMessageUserMentionElement | MemberChangeMessageRoomReferenceElement;

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 63 in src/libs/ReportActionsUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -224,6 +225,10 @@
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED);
}

function isDynamicExternalWorkflowSubmitAction(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED> {
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) && getOriginalMessage(reportAction)?.workflow === CONST.POLICY.APPROVAL_MODE.DYNAMICEXTERNAL;
}

function isMarkAsClosedAction(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.CLOSED> {
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.CLOSED) && !!getOriginalMessage(reportAction)?.amount;
}
Expand All @@ -240,6 +245,10 @@
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED);
}

function isDynamicExternalWorkflowForwardedAction(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED> {
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED) && getOriginalMessage(reportAction)?.workflow === CONST.POLICY.APPROVAL_MODE.DYNAMICEXTERNAL;
}

function isModifiedExpenseAction(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE> {
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE);
}
Expand Down Expand Up @@ -1104,6 +1113,43 @@
return actions.filter(isVisiblePreviewOrMoneyRequest);
}

function getDynamicExternalWorkflowRoutedAction(
reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED> | ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED>,
): ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED> {
return {
reportActionID: `${reportAction.reportActionID}DEW`,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@francoisl is it fine that I just append DEW to the report action ID of the concierge message?

This is so the ID is consistent every time getDynamicExternalWorkflowRoutedAction is called, so the "Copy message" context menu can work.

created: DateUtils.addMillisecondsFromDateTime(reportAction.created, 1),
Comment thread
bernhardoj marked this conversation as resolved.
actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED,
actorAccountID: CONST.ACCOUNT_ID.CONCIERGE,
message: [{html: 'DYNAMIC_EXTERNAL_WORKFLOW', type: 'COMMENT', text: ''}],
originalMessage: {
to: getOriginalMessage(reportAction)?.to ?? '',
},
};
}

function withDEWRoutedActionsArray(reportActions: ReportAction[]): ReportAction[] {
return reportActions.flatMap((reportAction) => {
if ((isDynamicExternalWorkflowSubmitAction(reportAction) || isDynamicExternalWorkflowForwardedAction(reportAction)) && getOriginalMessage(reportAction)?.to) {
return [reportAction, getDynamicExternalWorkflowRoutedAction(reportAction)];
}
return reportAction;
});
}

function withDEWRoutedActionsObject(reportActions: OnyxEntry<ReportActions>): OnyxEntry<ReportActions> {
return Object.entries(reportActions ?? {}).reduce((acc, value) => {
const [reportActionID, reportAction] = value;
acc[reportActionID] = reportAction;

if ((isDynamicExternalWorkflowSubmitAction(reportAction) || isDynamicExternalWorkflowForwardedAction(reportAction)) && getOriginalMessage(reportAction)?.to) {
const dynamicExternalWorkflowRoutedAction = getDynamicExternalWorkflowRoutedAction(reportAction);
acc[dynamicExternalWorkflowRoutedAction.reportActionID] = dynamicExternalWorkflowRoutedAction;
}
return acc;
}, {} as ReportActions);
}

/**
* This method returns the report actions that are ready for display in the ReportActionsView.
* The report actions need to be sorted by created timestamp first, and reportActionID second
Expand All @@ -1129,7 +1175,7 @@
}

const baseURLAdjustedReportActions = filteredReportActions.map((reportAction) => replaceBaseURLInPolicyChangeLogAction(reportAction));
return getSortedReportActions(baseURLAdjustedReportActions, true);
return getSortedReportActions(withDEWRoutedActionsArray(baseURLAdjustedReportActions), true);
}

/**
Expand Down Expand Up @@ -1946,6 +1992,12 @@
return [{text: message, html: message, type: 'COMMENT'}];
}

if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const message = getDynamicExternalWorkflowRoutedMessage(action, translateLocal);
return [{text: message, html: `<muted-text>${message}</muted-text>`, type: 'COMMENT'}];
}

const actionMessage = action.previousMessage ?? action.message;
if (Array.isArray(actionMessage)) {
return actionMessage.filter((item): item is Message => !!item);
Expand Down Expand Up @@ -3291,6 +3343,13 @@
return translate('reportAction.harvestCreatedExpenseReport', {reportUrl, reportName});
}

function getDynamicExternalWorkflowRoutedMessage(
action: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED>>,
translate: LocaleContextProps['translate'],
) {
return translate('iou.routedDueToDEW', {to: getOriginalMessage(action)?.to ?? ''});
Comment thread
bernhardoj marked this conversation as resolved.
}

function isCardIssuedAction(
reportAction: OnyxEntry<ReportAction>,
): reportAction is ReportAction<
Expand Down Expand Up @@ -3531,6 +3590,7 @@
getUpdatedApprovalRuleMessage,
getRemovedFromApprovalChainMessage,
getDemotedFromWorkspaceMessage,
getDynamicExternalWorkflowRoutedMessage,
getReportAction,
getReportActionHtml,
getReportActionMessage,
Expand Down Expand Up @@ -3604,8 +3664,10 @@
isWhisperAction,
isSubmittedAction,
isSubmittedAndClosedAction,
isDynamicExternalWorkflowSubmitAction,
isMarkAsClosedAction,
isApprovedAction,
isDynamicExternalWorkflowForwardedAction,
isUnapprovedAction,
isForwardedAction,
isWhisperActionTargetedToOthers,
Expand Down Expand Up @@ -3690,6 +3752,8 @@
getActionableCardFraudAlertMessage,
getHarvestCreatedExpenseReportMessage,
isSystemUserMentioned,
withDEWRoutedActionsArray,
withDEWRoutedActionsObject,
};

export type {LastVisibleMessage};
Loading
Loading