Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'Wähle einen Arbeitsbereich',
routedDueToDEW: (to: string) => `Report aufgrund des benutzerdefinierten Genehmigungsworkflows an ${to} weitergeleitet`,
routedDueToDEW: (to: string, reason?: string) => `Bericht weitergeleitet an ${to}${reason ? ` weil ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? 'Stunde' : 'Stunden'} @ ${rate} / Stunde`,
hrs: 'Std.',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ const translations = {
},
},
chooseWorkspace: 'Choose a workspace',
routedDueToDEW: (to: string) => `report routed to ${to} due to custom approval workflow`,
routedDueToDEW: (to: string, reason?: string) => `report routed to ${to}${reason ? ` because ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? 'hour' : 'hours'} @ ${rate} / hour`,
hrs: 'hrs',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'Elige un espacio de trabajo',
routedDueToDEW: (to) => `informe enviado a ${to} debido a un flujo de aprobación personalizado`,
routedDueToDEW: (to: string, reason?: string) => `informe enviado a ${to}${reason ? ` porque ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? 'hora' : 'horas'} a ${rate} / hora`,
hrs: 'h',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'Choisir un espace de travail',
routedDueToDEW: (to: string) => `note de frais transmise à ${to} en raison du flux d’approbation personnalisé`,
routedDueToDEW: (to: string, reason?: string) => `note de frais acheminée vers ${to}${reason ? ` parce que ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? 'heure' : 'heures'} @ ${rate} / heure`,
hrs: 'h',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'Scegli uno spazio di lavoro',
routedDueToDEW: (to: string) => `rendiconto instradato a ${to} a causa del flusso di approvazione personalizzato`,
routedDueToDEW: (to: string, reason?: string) => `report indirizzato a ${to}${reason ? ` perché ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? 'ora' : 'ore'} @ ${rate} / ora`,
hrs: 'ore',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'ワークスペースを選択',
routedDueToDEW: (to: string) => `カスタム承認ワークフローにより、レポートは${to}に回付されました`,
routedDueToDEW: (to: string, reason?: string) => `レポートは ${to}${reason ? ` ${reason} のため` : ''} に回覧されました`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? '時間' : '時間'} @ ${rate} / 時間`,
hrs: '時間',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'Kies een werkruimte',
routedDueToDEW: (to: string) => `rapport doorgestuurd naar ${to} vanwege aangepast goedkeuringsworkflow`,
routedDueToDEW: (to: string, reason?: string) => `rapport doorgestuurd naar ${to}${reason ? ` omdat ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? 'uur' : 'uren'} @ ${rate} / uur`,
hrs: 'uur',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'Wybierz przestrzeń roboczą',
routedDueToDEW: (to: string) => `raport skierowano do ${to} z powodu niestandardowego przepływu zatwierdzania`,
routedDueToDEW: (to: string, reason?: string) => `raport przekazany do ${to}${reason ? ` bo ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? 'godzina' : 'godziny'} @ ${rate} / godzinę`,
hrs: 'godz.',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: 'Escolha um workspace',
routedDueToDEW: (to: string) => `relatório encaminhado para ${to} devido ao fluxo de aprovação personalizado`,
routedDueToDEW: (to: string, reason?: string) => `relatório encaminhado para ${to}${reason ? ` porque ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? 'hora' : 'horas'} @ ${rate} / hora`,
hrs: 'h',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ const translations: TranslationDeepObject<typeof en> = {
},
},
chooseWorkspace: '选择工作区',
routedDueToDEW: (to: string) => `报表因自定义审批流程被转交给 ${to}`,
routedDueToDEW: (to: string, reason?: string) => `报销单已转交给 ${to}${reason ? ` 因为 ${reason}` : ''}`,
timeTracking: {
hoursAt: (hours: number, rate: string) => `${hours} ${hours === 1 ? '小时' : '小时'},按 ${rate} / 小时`,
hrs: '小时',
Expand Down
7 changes: 5 additions & 2 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}

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

Check warning on line 91 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 All @@ -100,7 +100,7 @@
});

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

Check warning on line 103 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,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -109,13 +109,13 @@
});

let isNetworkOffline = false;
Onyx.connect({

Check warning on line 112 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.NETWORK,
callback: (val) => (isNetworkOffline = val?.isOffline ?? false),
});

let deprecatedCurrentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 118 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.SESSION,
callback: (value) => {
// When signed out, value is undefined
Expand Down Expand Up @@ -1433,14 +1433,16 @@
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> {
const originalMessage = getOriginalMessage(reportAction);
return {
reportActionID: `${reportAction.reportActionID}DEW`,
created: DateUtils.addMillisecondsFromDateTime(reportAction.created, 1),
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 ?? '',
to: originalMessage?.to ?? '',
message: originalMessage?.message ?? '',
},
};
}
Expand Down Expand Up @@ -4132,7 +4134,8 @@
action: OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED>>,
translate: LocaleContextProps['translate'],
) {
return translate('iou.routedDueToDEW', getOriginalMessage(action)?.to ?? '');
const originalMessage = getOriginalMessage(action);
return translate('iou.routedDueToDEW', originalMessage?.to ?? '', originalMessage?.message ?? '');
}

function getSettlementAccountLockedMessage(translate: LocalizedTranslate, action: OnyxEntry<ReportAction>): string {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/inbox/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@
clearError(transactionID);
}
clearAllRelatedReportActionErrors(reportID, action, originalReportID);
}, [action, isSendingMoney, reportID, clearAllRelatedReportActionErrors, report, chatReport, clearError]);

Check warning on line 637 in src/pages/inbox/report/PureReportActionItem.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has a missing dependency: 'originalReportID'. Either include it or remove the dependency array

const showDismissReceiptErrorModal = useCallback(async () => {
const result = await showConfirmModal({
Expand Down Expand Up @@ -1355,6 +1355,9 @@
);
} else if (hasPendingDEWSubmit(reportMetadata, isDEWPolicy) && isPendingAdd) {
children = <ReportActionItemBasicMessage message={translate('iou.queuedToSubmitViaDEW')} />;
} else if (isDEWPolicy) {
// Don't show a memo for DEW actions, it's shown in the Concierge action below
children = <ReportActionItemBasicMessage message={translate('iou.submitted')} />;
} else {
children = <ReportActionItemBasicMessage message={translate('iou.submitted', getOriginalMessage(action)?.message)} />;
}
Expand Down
6 changes: 6 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,9 @@ type OriginalMessageDismissedViolation = {
type OriginalMessageDynamicExternalWorkflowRouted = {
/** The approver of the report is submitted to */
to: string;

/** Explanation for why the report was routed that way */
message?: string;
};

/** Model of `marked reimbursed` report action */
Expand Down Expand Up @@ -1110,6 +1113,9 @@ type OriginalMessageForwarded = {

/** The workflow the report is approved on */
workflow?: ValueOf<typeof CONST.POLICY.APPROVAL_MODE>;

/** Optional message explaining why the report was forwarded that way */
message?: string;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/OptionsListUtilsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4564,7 +4564,7 @@ describe('OptionsListUtils', () => {
created: '',
actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED,
message: [{type: 'COMMENT', text: ''}],
originalMessage: {to: 'example@gmail.com'},
originalMessage: {to: 'example@gmail.com', message: ''},
};
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, {
[action.reportActionID]: action,
Expand Down
32 changes: 26 additions & 6 deletions tests/unit/ReportActionsUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ describe('ReportActionsUtils', () => {
message: [],
originalMessage: {
to: 'example@gmail.com',
message: '',
},
};

Expand Down Expand Up @@ -2641,15 +2642,15 @@ describe('ReportActionsUtils', () => {
reportActionID: '2',
originalMessage: {workflow: CONST.POLICY.APPROVAL_MODE.DYNAMICEXTERNAL, to: 'example@gmail.com'},
},
{actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED, reportActionID: '2DEW', originalMessage: {to: 'example@gmail.com'}},
{actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED, reportActionID: '2DEW', originalMessage: {to: 'example@gmail.com', message: ''}},
{actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, created: '', reportActionID: '3'},
{
actionName: CONST.REPORT.ACTIONS.TYPE.FORWARDED,
created: '',
reportActionID: '4',
originalMessage: {workflow: CONST.POLICY.APPROVAL_MODE.DYNAMICEXTERNAL, to: 'example2@gmail.com'},
},
{actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED, reportActionID: '4DEW', originalMessage: {to: 'example2@gmail.com'}},
{actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED, reportActionID: '4DEW', originalMessage: {to: 'example2@gmail.com', message: ''}},
];
const actual = ReportActionsUtils.withDEWRoutedActionsArray(reportActions);

Expand Down Expand Up @@ -2710,12 +2711,12 @@ describe('ReportActionsUtils', () => {
const secondDEWAction = {
actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED,
reportActionID: '2DEW',
originalMessage: {to: 'example@gmail.com'},
originalMessage: {to: 'example@gmail.com', message: ''},
} as ReportAction;
const fourthDEWAction = {
actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED,
reportActionID: '4DEW',
originalMessage: {to: 'example2@gmail.com'},
originalMessage: {to: 'example2@gmail.com', message: ''},
} as ReportAction;
const expected: ReportActions = {
[firstAction.reportActionID]: firstAction,
Expand Down Expand Up @@ -2766,14 +2767,33 @@ describe('ReportActionsUtils', () => {
reportActionID: '1',
actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED,
created: '',
originalMessage: {to},
originalMessage: {to, message: ''},
};

// When getting the DYNAMIC_EXTERNAL_WORKFLOW_ROUTED action message
const actual = ReportActionsUtils.getDynamicExternalWorkflowRoutedMessage(action, translateLocal);

// Then it should return the routed due to DEW message with the correct "to" value
const expected = translateLocal('iou.routedDueToDEW', to);
const expected = translateLocal('iou.routedDueToDEW', to, '');
expect(actual).toBe(expected);
});

it('should return the routed message with reason', () => {
// Given a DYNAMIC_EXTERNAL_WORKFLOW_ROUTED action with a reason message
const to = 'example@gmail.com';
const reason = 'the report total exceeds the auto-approval limit';
const action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED> = {
reportActionID: '1',
actionName: CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED,
created: '',
originalMessage: {to, message: reason},
};

// When getting the DYNAMIC_EXTERNAL_WORKFLOW_ROUTED action message
const actual = ReportActionsUtils.getDynamicExternalWorkflowRoutedMessage(action, translateLocal);

// Then it should return the routed due to DEW message with the correct "to" value and reason
const expected = translateLocal('iou.routedDueToDEW', to, reason);
expect(actual).toBe(expected);
});
});
Expand Down
Loading