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
4 changes: 4 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,10 @@ const translations: TranslationDeepObject<typeof en> = {
formatPersonalRules: (fragments: string, route: string) => `${fragments} über <a href="${route}">Regeln für persönliche Ausgaben</a>`,
formatPolicyRules: (fragments: string, route: string) => `${fragments} über <a href="${route}">Workspace-Regeln</a>`,
},
failedToAutoSubmitViaDEW: (reason: string) => `Senden des Berichts über <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">Übermittlungen verzögern</a> fehlgeschlagen. ${reason}`,
failedToSubmitViaDEW: (reason: string) => `Der Bericht konnte nicht übermittelt werden. ${reason}`,
failedToAutoApproveViaDEW: (reason: string) => `Genehmigung über <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">Workspace-Regeln</a> fehlgeschlagen. ${reason}`,
failedToApproveViaDEW: (reason: string) => `Genehmigung fehlgeschlagen. ${reason}`,
},
transactionMerge: {
listPage: {
Expand Down
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,10 @@ const translations = {
submitted: (memo?: string) => `submitted${memo ? `, saying ${memo}` : ''}`,
automaticallySubmitted: `submitted via <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">delay submissions</a>`,
queuedToSubmitViaDEW: 'queued to submit via custom approval workflow',
failedToAutoSubmitViaDEW: (reason: string) => `failed to submit the report via <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">delay submissions</a>. ${reason}`,
failedToSubmitViaDEW: (reason: string) => `failed to submit the report. ${reason}`,
failedToAutoApproveViaDEW: (reason: string) => `failed to approve via <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">workspace rules</a>. ${reason}`,
failedToApproveViaDEW: (reason: string) => `failed to approve. ${reason}`,
queuedToApproveViaDEW: 'queued to approve via custom approval workflow',
trackedAmount: (formattedAmount: string, comment?: string) => `tracking ${formattedAmount}${comment ? ` for ${comment}` : ''}`,
splitAmount: (amount: string) => `split ${amount}`,
Expand Down
5 changes: 5 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,11 @@ const translations: TranslationDeepObject<typeof en> = {
submitted: (memo) => `enviado${memo ? `, dijo ${memo}` : ''}`,
automaticallySubmitted: `envió mediante <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">retrasar envíos</a>`,
queuedToSubmitViaDEW: 'en cola para enviar a través del flujo de aprobación personalizado',
failedToAutoSubmitViaDEW: (reason: string) => `no ha podido enviar este informe mediante <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">retrasar envíos</a>. ${reason}`,
failedToSubmitViaDEW: (reason: string) => `no ha podido enviar este informe. ${reason}`,
failedToAutoApproveViaDEW: (reason: string) =>
`no ha podido aprobar mediante <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">reglas del espacio de trabajo</a>. ${reason}`,
failedToApproveViaDEW: (reason: string) => `no ha podido aprobar. ${reason}`,
queuedToApproveViaDEW: 'en cola para aprobar a través del flujo de aprobación personalizado',
trackedAmount: (formattedAmount, comment) => `realizó un seguimiento de ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
splitAmount: (amount) => `dividir ${amount}`,
Expand Down
5 changes: 5 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,11 @@ const translations: TranslationDeepObject<typeof en> = {
formatPersonalRules: (fragments: string, route: string) => `${fragments} via <a href="${route}">règles de dépenses personnelles</a>`,
formatPolicyRules: (fragments: string, route: string) => `${fragments} via <a href="${route}">règles d’espace de travail</a>`,
},
failedToAutoSubmitViaDEW: (reason: string) => `échec de la soumission de la note de frais via <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">soumissions différées</a>. ${reason}`,
failedToSubmitViaDEW: (reason: string) => `échec de la soumission de la note de frais. ${reason}`,
failedToAutoApproveViaDEW: (reason: string) =>
`impossible d’approuver via les <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">règles de l’espace de travail</a>. ${reason}`,
failedToApproveViaDEW: (reason: string) => `échec de l’approbation. ${reason}`,
},
transactionMerge: {
listPage: {
Expand Down
5 changes: 5 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,11 @@ const translations: TranslationDeepObject<typeof en> = {
formatPersonalRules: (fragments: string, route: string) => `${fragments} tramite <a href="${route}">regole spese personali</a>`,
formatPolicyRules: (fragments: string, route: string) => `${fragments} tramite <a href="${route}">regole spazio di lavoro</a>`,
},
failedToAutoSubmitViaDEW: (reason: string) => `invio del resoconto non riuscito tramite <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">rimanda invii</a>. ${reason}`,
failedToSubmitViaDEW: (reason: string) => `invio del rapporto non riuscito. ${reason}`,
failedToAutoApproveViaDEW: (reason: string) =>
`approvazione non riuscita tramite le <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">regole dello spazio di lavoro</a>. ${reason}`,
failedToApproveViaDEW: (reason: string) => `approvazione non riuscita. ${reason}`,
},
transactionMerge: {
listPage: {
Expand Down
4 changes: 4 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,10 @@ const translations: TranslationDeepObject<typeof en> = {
formatPersonalRules: (fragments: string, route: string) => `${fragments} (<a href="${route}">個人経費ルール</a> 経由)`,
formatPolicyRules: (fragments: string, route: string) => `${fragments} (<a href="${route}">ワークスペースルール</a> 経由)`,
},
failedToAutoSubmitViaDEW: (reason: string) => `<a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">提出を遅らせる</a>を使ったレポートの送信に失敗しました。${reason}`,
failedToSubmitViaDEW: (reason: string) => `レポートの送信に失敗しました。${reason}`,
failedToAutoApproveViaDEW: (reason: string) => `<a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">ワークスペースルール</a>で承認に失敗しました。${reason}`,
failedToApproveViaDEW: (reason: string) => `承認に失敗しました。${reason}`,
},
transactionMerge: {
listPage: {
Expand Down
4 changes: 4 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,10 @@ const translations: TranslationDeepObject<typeof en> = {
formatPersonalRules: (fragments: string, route: string) => `${fragments} via <a href="${route}">persoonlijke onkostregels</a>`,
formatPolicyRules: (fragments: string, route: string) => `${fragments} via <a href="${route}">werkruimte­regels</a>`,
},
failedToAutoSubmitViaDEW: (reason: string) => `rapport indienen via <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">indiening uitstellen</a> is mislukt. ${reason}`,
failedToSubmitViaDEW: (reason: string) => `het is niet gelukt om het rapport in te dienen. ${reason}`,
failedToAutoApproveViaDEW: (reason: string) => `goedkeuren via <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">werkruimte­regels</a> is mislukt. ${reason}`,
failedToApproveViaDEW: (reason: string) => `goedkeuren mislukt. ${reason}`,
},
transactionMerge: {
listPage: {
Expand Down
5 changes: 5 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,11 @@ const translations: TranslationDeepObject<typeof en> = {
formatPersonalRules: (fragments: string, route: string) => `${fragments} przez <a href="${route}">zasady wydatków prywatnych</a>`,
formatPolicyRules: (fragments: string, route: string) => `${fragments} przez <a href="${route}">zasady workspace’u</a>`,
},
failedToAutoSubmitViaDEW: (reason: string) => `nie udało się przesłać raportu przez <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">opóźnianie wysyłki</a>. ${reason}`,
failedToSubmitViaDEW: (reason: string) => `nie udało się wysłać raportu. ${reason}`,
failedToAutoApproveViaDEW: (reason: string) =>
`nie udało się zatwierdzić przez <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">zasady w przestrzeni roboczej</a>. ${reason}`,
failedToApproveViaDEW: (reason: string) => `nie udało się zaakceptować. ${reason}`,
},
transactionMerge: {
listPage: {
Expand Down
4 changes: 4 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,10 @@ const translations: TranslationDeepObject<typeof en> = {
formatPersonalRules: (fragments: string, route: string) => `${fragments} via <a href="${route}">regras de despesas pessoais</a>`,
formatPolicyRules: (fragments: string, route: string) => `${fragments} via <a href="${route}">regras do workspace</a>`,
},
failedToAutoSubmitViaDEW: (reason: string) => `falha ao enviar o relatório via <a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">adiar envios</a>. ${reason}`,
failedToSubmitViaDEW: (reason: string) => `falha ao enviar o relatório. ${reason}`,
failedToAutoApproveViaDEW: (reason: string) => `falha ao aprovar pelas <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">regras do workspace</a>. ${reason}`,
failedToApproveViaDEW: (reason: string) => `falha ao aprovar. ${reason}`,
},
transactionMerge: {
listPage: {
Expand Down
4 changes: 4 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,10 @@ const translations: TranslationDeepObject<typeof en> = {
formatPersonalRules: (fragments: string, route: string) => `${fragments} 通过 <a href="${route}">个人报销规则</a>`,
formatPolicyRules: (fragments: string, route: string) => `${fragments} 通过 <a href="${route}">工作区规则</a>`,
},
failedToAutoSubmitViaDEW: (reason: string) => `通过<a href="${CONST.SELECT_WORKFLOWS_HELP_URL}">延迟提交</a>提交报表失败。${reason}`,
failedToSubmitViaDEW: (reason: string) => `报表提交失败。${reason}`,
failedToAutoApproveViaDEW: (reason: string) => `未能通过<a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">工作区规则</a>批准。${reason}`,
failedToApproveViaDEW: (reason: string) => `批准失败。${reason}`,
},
transactionMerge: {
listPage: {
Expand Down
18 changes: 18 additions & 0 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 @@ -885,6 +885,8 @@
return reportAction?.actorAccountID;
}

case CONST.REPORT.ACTIONS.TYPE.DEW_SUBMIT_FAILED:
case CONST.REPORT.ACTIONS.TYPE.DEW_APPROVE_FAILED:
case CONST.REPORT.ACTIONS.TYPE.SUBMITTED:
case CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED:
case CONST.REPORT.ACTIONS.TYPE.APPROVED:
Expand Down Expand Up @@ -2301,6 +2303,22 @@
return [{text: message, html: `<muted-text>${message}</muted-text>`, type: 'COMMENT'}];
}

if (isDynamicExternalWorkflowSubmitFailedAction(action)) {
const originalMessage = getOriginalMessage(action);
const wasSubmittedViaHarvesting = originalMessage?.harvesting ?? false;
const message = originalMessage?.message ?? translate('iou.error.genericCreateFailureMessage');
const failedSubmitReason = wasSubmittedViaHarvesting ? translate('iou.failedToAutoSubmitViaDEW', message) : translate('iou.failedToSubmitViaDEW', message);
return [{text: failedSubmitReason, html: `<muted-text>${failedSubmitReason}</muted-text>`, type: 'COMMENT'}];
}

if (isDynamicExternalWorkflowApproveFailedAction(action)) {
const originalMessage = getOriginalMessage(action);
const wasAutoApproveAction = originalMessage?.automaticAction ?? false;
const message = originalMessage?.message ?? translate('iou.error.genericCreateFailureMessage');
const failedApproveReason = wasAutoApproveAction ? translate('iou.failedToAutoApproveViaDEW', message) : translate('iou.failedToApproveViaDEW', message);
return [{text: failedApproveReason, html: `<muted-text>${failedApproveReason}</muted-text>`, type: 'COMMENT'}];
}

const actionMessage = action.previousMessage ?? action.message;
if (Array.isArray(actionMessage)) {
return actionMessage.filter((item): item is Message => !!item);
Expand Down
8 changes: 0 additions & 8 deletions src/pages/inbox/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@
isCreatedTaskReportAction,
isDeletedAction,
isDeletedParentAction as isDeletedParentActionUtils,
isDynamicExternalWorkflowApproveFailedAction,
isDynamicExternalWorkflowSubmitFailedAction,
isIOURequestReportAction,
isMarkAsClosedAction,
isMessageDeleted,
Expand Down Expand Up @@ -635,7 +633,7 @@
clearError(transactionID);
}
clearAllRelatedReportActionErrors(reportID, action, originalReportID);
}, [action, isSendingMoney, reportID, clearAllRelatedReportActionErrors, report, chatReport, clearError]);

Check warning on line 636 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 @@ -1361,12 +1359,6 @@
} else {
children = <ReportActionItemBasicMessage message={translate('iou.approvedMessage')} />;
}
} else if (isDynamicExternalWorkflowSubmitFailedAction(action)) {
const errorMessage = getOriginalMessage(action)?.message ?? translate('iou.error.genericCreateFailureMessage');
children = <ReportActionItemBasicMessage message={errorMessage} />;
} else if (isDynamicExternalWorkflowApproveFailedAction(action)) {
const errorMessage = getOriginalMessage(action)?.message ?? translate('iou.error.genericCreateFailureMessage');
children = <ReportActionItemBasicMessage message={errorMessage} />;
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.IOU) && getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
const wasAutoPaid = getOriginalMessage(action)?.automaticAction ?? false;
const paymentType = getOriginalMessage(action)?.paymentType;
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,9 @@ type OriginalMessageDEWFailed = {

/** Whether the action was automatic */
automaticAction?: boolean;

/** Was the report submitted via harvesting (delayed submit) */
harvesting?: boolean;
};

/**
Expand Down
75 changes: 75 additions & 0 deletions tests/unit/ReportActionsUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,81 @@ describe('ReportActionsUtils', () => {
// Then it should return the correct message fragments
expect(expectedFragments).toEqual([{text: expectedMessage, html: `<muted-text>${expectedMessage}</muted-text>`, type: 'COMMENT'}]);
});

it('should return the correct fragment for DEW_SUBMIT_FAILED with harvesting', () => {
const errorMessage = 'All expenses must be categorized before submitting';
const action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DEW_SUBMIT_FAILED> = {
actionName: CONST.REPORT.ACTIONS.TYPE.DEW_SUBMIT_FAILED,
reportActionID: '1',
created: '1',
message: [],
originalMessage: {
message: errorMessage,
harvesting: true,
},
};

const fragments = ReportActionsUtils.getReportActionMessageFragments(translateLocal, action);
const expectedText = translateLocal('iou.failedToAutoSubmitViaDEW', errorMessage);
const expectedHtml = `<muted-text>${expectedText}</muted-text>`;
expect(fragments).toEqual([{text: expectedText, html: expectedHtml, type: 'COMMENT'}]);
});

it('should return the correct fragment for DEW_SUBMIT_FAILED without harvesting', () => {
const errorMessage = 'All expenses must be categorized before submitting';
const action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DEW_SUBMIT_FAILED> = {
actionName: CONST.REPORT.ACTIONS.TYPE.DEW_SUBMIT_FAILED,
reportActionID: '1',
created: '1',
message: [],
originalMessage: {
message: errorMessage,
},
};

const fragments = ReportActionsUtils.getReportActionMessageFragments(translateLocal, action);
const expectedText = translateLocal('iou.failedToSubmitViaDEW', errorMessage);
const expectedHtml = `<muted-text>${expectedText}</muted-text>`;
expect(fragments).toEqual([{text: expectedText, html: expectedHtml, type: 'COMMENT'}]);
});

it('should return the correct fragment for DEW_APPROVE_FAILED with automaticAction', () => {
const errorMessage = 'This report cannot be approved';
const action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DEW_APPROVE_FAILED> = {
actionName: CONST.REPORT.ACTIONS.TYPE.DEW_APPROVE_FAILED,
reportActionID: '1',
created: '1',
message: [],
originalMessage: {
message: errorMessage,
automaticAction: true,
},
};

const fragments = ReportActionsUtils.getReportActionMessageFragments(translateLocal, action);
const expectedText = translateLocal('iou.failedToAutoApproveViaDEW', errorMessage);
const expectedHtml = `<muted-text>${expectedText}</muted-text>`;
expect(fragments).toEqual([{text: expectedText, html: expectedHtml, type: 'COMMENT'}]);
});

it('should return the correct fragment for DEW_APPROVE_FAILED without automaticAction', () => {
const errorMessage = 'This report cannot be approved';
const action: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.DEW_APPROVE_FAILED> = {
actionName: CONST.REPORT.ACTIONS.TYPE.DEW_APPROVE_FAILED,
reportActionID: '1',
created: '1',
message: [],
originalMessage: {
message: errorMessage,
automaticAction: false,
},
};

const fragments = ReportActionsUtils.getReportActionMessageFragments(translateLocal, action);
const expectedText = translateLocal('iou.failedToApproveViaDEW', errorMessage);
const expectedHtml = `<muted-text>${expectedText}</muted-text>`;
expect(fragments).toEqual([{text: expectedText, html: expectedHtml, type: 'COMMENT'}]);
});
});

describe('getSendMoneyFlowAction', () => {
Expand Down
Loading