diff --git a/src/CONST/index.ts b/src/CONST/index.ts index f5609e5d163d..2cb82ab895cb 100644 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -2224,6 +2224,7 @@ const CONST = { WAITING_TO_APPROVE: 'waitingToApprove', WAITING_TO_PAY: 'waitingToPay', WAITING_FOR_PAYMENT: 'waitingForPayment', + WAITING_FOR_CANCELLED_REIMBURSEMENT: 'waitingForCancelledReimbursement', WAITING_TO_EXPORT: 'waitingToExport', SUBMITTING_TO_SELF: 'submittingToSelf', REJECTED_REPORT: 'rejectedReport', diff --git a/src/languages/de.ts b/src/languages/de.ts index 9443b7ef5276..c57c5f7c4791 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -2184,6 +2184,18 @@ const translations: TranslationDeepObject = { } return `Warten, bis die Zahlung abgeschlossen ist${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` bis ${eta}` : ` ${eta}`; + } + return `Warten, bis die stornierte Zahlung vollständig verarbeitet ist${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/el.ts b/src/languages/el.ts index 45c848e2985e..753c20c5bd6e 100644 --- a/src/languages/el.ts +++ b/src/languages/el.ts @@ -2229,6 +2229,18 @@ const translations: TranslationDeepObject = { } return `Αναμονή για την ολοκλήρωση της πληρωμής${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` έως ${eta}` : ` ${eta}`; + } + return `Αναμονή για την ολοκλήρωση της επεξεργασίας της ακυρωμένης πληρωμής${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/en.ts b/src/languages/en.ts index 082a4aed7b8d..de05c2f0b13a 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2328,6 +2328,19 @@ const translations = { return `Waiting for payment to complete${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` by ${eta}` : ` ${eta}`; + } + + return `Waiting for the cancelled payment to finish processing${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/es.ts b/src/languages/es.ts index 5a4f6962d2ca..46050d856a26 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2105,6 +2105,13 @@ const translations: TranslationDeepObject = { } return `Esperando a que se complete el pago${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (_actor, _actorType, eta, etaType) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` para el ${eta}` : ` ${eta}`; + } + return `Esperando a que termine de procesarse el pago cancelado${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: (_actor, _actorType, _eta, _etaType) => `¡Ups! Parece que estás enviando el informe a ti mismo. Aprobar tus propios informes está prohibido por tu espacio de trabajo. Por favor, envía este informe a otra persona o contacta a tu administrador para cambiar la persona a la que lo envías.`, [CONST.NEXT_STEP.MESSAGE_KEY.REJECTED_REPORT]: (actor, actorType) => { diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 1397788a7159..4dba8ab61289 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -2189,6 +2189,18 @@ const translations: TranslationDeepObject = { } return `En attente de la finalisation du paiement${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` d’ici ${eta}` : ` ${eta}`; + } + return `En attente de la fin du traitement du paiement annulé${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/it.ts b/src/languages/it.ts index 9b5a9461ab45..8eac71653d18 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -2177,6 +2177,18 @@ const translations: TranslationDeepObject = { } return `In attesa che il pagamento venga completato${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` entro le ${eta}` : ` ${eta}`; + } + return `In attesa che il pagamento annullato completi l'elaborazione${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/ja.ts b/src/languages/ja.ts index d4b6395a03d0..ed28d87988ba 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -2159,6 +2159,18 @@ const translations: TranslationDeepObject = { } return `支払いの完了を待機しています${formattedETA}。`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? `${eta}までに` : ` ${eta}`; + } + return `キャンセルされた支払いの処理完了を待機しています${formattedETA}。`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 4fd0023754ec..3cc97b78e58c 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -2175,6 +2175,18 @@ const translations: TranslationDeepObject = { } return `Wachten tot de betaling is voltooid${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` vóór ${eta}` : ` ${eta}`; + } + return `Wachten tot de geannuleerde betaling is verwerkt${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/pl.ts b/src/languages/pl.ts index 829cfa260527..801dff8414bf 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -2211,6 +2211,18 @@ const translations: TranslationDeepObject = { } return `Oczekiwanie na zakończenie płatności${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` do ${eta}` : ` ${eta}`; + } + return `Oczekiwanie na zakończenie przetwarzania anulowanej płatności${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index c48f53b822ab..973dbbe0862f 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -2168,6 +2168,18 @@ const translations: TranslationDeepObject = { } return `Aguardando o pagamento ser concluído${formattedETA}.`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? ` até ${eta}` : ` ${eta}`; + } + return `Aguardando a conclusão do processamento do pagamento cancelado${formattedETA}.`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 80c14fa5170f..19b4f04f8791 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -2099,6 +2099,18 @@ const translations: TranslationDeepObject = { } return `正在等待付款完成${formattedETA}。`; }, + [CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: ( + _actor: string, + _actorType: ValueOf, + eta?: string, + etaType?: ValueOf, + ) => { + let formattedETA = ''; + if (eta) { + formattedETA = etaType === CONST.NEXT_STEP.ETA_TYPE.DATE_TIME ? `于 ${eta} 前` : ` ${eta}`; + } + return `正在等待已取消的付款完成处理${formattedETA}。`; + }, [CONST.NEXT_STEP.MESSAGE_KEY.SUBMITTING_TO_SELF]: ( _actor: string, _actorType: ValueOf, diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 8c8361be9712..04e61919e409 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -493,6 +493,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa case 'isDeletedParentAction': case 'isWaitingOnBankAccount': case 'canCancelReimbursement': + case 'isWaitingForCancelledReimbursement': case 'hasReportBeenRetracted': case 'isCancelledIOU': case 'hasReportBeenReopened': @@ -678,6 +679,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa unheldReimbursableTotal: CONST.RED_BRICK_ROAD_PENDING_ACTION, isWaitingOnBankAccount: CONST.RED_BRICK_ROAD_PENDING_ACTION, canCancelReimbursement: CONST.RED_BRICK_ROAD_PENDING_ACTION, + isWaitingForCancelledReimbursement: CONST.RED_BRICK_ROAD_PENDING_ACTION, isCancelledIOU: CONST.RED_BRICK_ROAD_PENDING_ACTION, hasReportBeenRetracted: CONST.RED_BRICK_ROAD_PENDING_ACTION, hasReportBeenReopened: CONST.RED_BRICK_ROAD_PENDING_ACTION, diff --git a/src/libs/ReportPreviewActionUtils.ts b/src/libs/ReportPreviewActionUtils.ts index 9a9565440887..bf2cff9a5523 100644 --- a/src/libs/ReportPreviewActionUtils.ts +++ b/src/libs/ReportPreviewActionUtils.ts @@ -31,7 +31,7 @@ import { isInvoiceReport, isIOUReport, isOpenReport, - isPayBlockedByArchivedState, + isPayBlocked, isPayer, isProcessingReport, isReportApproved, @@ -136,7 +136,7 @@ function canPay( ) { const isExpense = isExpenseReport(report); - if (isPayBlockedByArchivedState(report, policy, isReportArchived)) { + if (isPayBlocked(report, policy, isReportArchived)) { return false; } diff --git a/src/libs/ReportPrimaryActionUtils.ts b/src/libs/ReportPrimaryActionUtils.ts index 497cb552a050..1f0c7cbbfa0c 100644 --- a/src/libs/ReportPrimaryActionUtils.ts +++ b/src/libs/ReportPrimaryActionUtils.ts @@ -51,7 +51,7 @@ import { isInvoiceReport as isInvoiceReportUtils, isIOUReport as isIOUReportUtils, isOpenReport as isOpenReportUtils, - isPayBlockedByArchivedState, + isPayBlocked, isPayer, isProcessingReport as isProcessingReportUtils, isReportApproved as isReportApprovedUtils, @@ -222,7 +222,7 @@ function isPrimaryPayAction({ }: IsPrimaryPayActionParams) { const isExpenseReport = isExpenseReportUtils(report); - if (isPayBlockedByArchivedState(report, policy, isArchivedReport(reportNameValuePairs) || !!isChatReportArchived)) { + if (isPayBlocked(report, policy, isArchivedReport(reportNameValuePairs) || !!isChatReportArchived)) { return false; } if (isExpenseReport && !isPaidGroupPolicy(policy)) { diff --git a/src/libs/ReportSecondaryActionUtils.ts b/src/libs/ReportSecondaryActionUtils.ts index 8bc716e0f830..cee78934653a 100644 --- a/src/libs/ReportSecondaryActionUtils.ts +++ b/src/libs/ReportSecondaryActionUtils.ts @@ -400,7 +400,7 @@ function isUnapproveAction(currentUserLogin: string, currentUserAccountID: numbe const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; const isManager = report.managerID === currentUserAccountID; - if (isReportSettled || !isExpenseReport || !isReportApproved || isPaymentProcessing) { + if (isReportSettled || !isExpenseReport || !isReportApproved || isPaymentProcessing || report.isWaitingForCancelledReimbursement) { return false; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c6094c6b8030..f6f32d2ca2db 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3306,7 +3306,7 @@ function canIOUBePaid( ) { const iouSettled = isSettled(iouReport); - if (isEmptyObject(iouReport)) { + if (isEmptyObject(iouReport) || iouReport.isWaitingForCancelledReimbursement) { return false; } @@ -14505,6 +14505,11 @@ function isPayBlockedByArchivedState(report: OnyxInputOrEntry, policy: O return isExpenseReport(report) ? isArchivedOrPendingDeletePolicy(policy) : isReportOrChatArchived; } +/** Whether Pay is blocked, either by archived state or by a cancelled payment that is still going back to the payer. */ +function isPayBlocked(report: OnyxInputOrEntry, policy: OnyxInputOrEntry, isReportOrChatArchived: boolean): boolean { + return isPayBlockedByArchivedState(report, policy, isReportOrChatArchived) || !!report?.isWaitingForCancelledReimbursement; +} + function hasReportBeenReopened(report: OnyxEntry, reportActions?: OnyxEntry | ReportAction[]): boolean { if (report?.hasReportBeenReopened !== undefined) { return report.hasReportBeenReopened; @@ -15553,7 +15558,7 @@ export { pushTransactionAutoSelectionsOnyxData, navigateOnDeleteExpense, canRejectReportAction, - isPayBlockedByArchivedState, + isPayBlocked, hasReportBeenRejectedToSubmitter, hasReportBeenReopened, hasReportBeenRetracted, diff --git a/src/selectors/Report.ts b/src/selectors/Report.ts index c5fb7a5005b9..23aa04a70bd2 100644 --- a/src/selectors/Report.ts +++ b/src/selectors/Report.ts @@ -364,6 +364,7 @@ function getStableReportSelector(report: OnyxEntry) { errors: report.errors, isWaitingOnBankAccount: report.isWaitingOnBankAccount, canCancelReimbursement: report.canCancelReimbursement, + isWaitingForCancelledReimbursement: report.isWaitingForCancelledReimbursement, isCancelledIOU: report.isCancelledIOU, hasReportBeenRetracted: report.hasReportBeenRetracted, hasReportBeenReopened: report.hasReportBeenReopened, diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 18055b381c89..f20475611aed 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -225,6 +225,9 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** Whether Auth still allows the bank reimbursement to be cancelled, returned by OpenReport */ canCancelReimbursement?: boolean; + /** Whether the report can't be paid until the cancelled reimbursement finishes processing */ + isWaitingForCancelledReimbursement?: boolean; + isCancelledIOU?: boolean; hasReportBeenRetracted?: boolean; hasReportBeenReopened?: boolean; diff --git a/src/types/utils/whitelistedReportKeys.ts b/src/types/utils/whitelistedReportKeys.ts index 1a4c786da824..95758837816c 100644 --- a/src/types/utils/whitelistedReportKeys.ts +++ b/src/types/utils/whitelistedReportKeys.ts @@ -64,6 +64,7 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback< errors: unknown; isWaitingOnBankAccount: unknown; canCancelReimbursement: unknown; + isWaitingForCancelledReimbursement: unknown; isCancelledIOU: unknown; hasReportBeenRetracted: unknown; hasReportBeenReopened: unknown; diff --git a/tests/unit/ReportPrimaryActionUtilsTest.ts b/tests/unit/ReportPrimaryActionUtilsTest.ts index 32ad04c2491d..03e481c6d572 100644 --- a/tests/unit/ReportPrimaryActionUtilsTest.ts +++ b/tests/unit/ReportPrimaryActionUtilsTest.ts @@ -1089,6 +1089,43 @@ describe('getPrimaryAction', () => { ).not.toBe(CONST.REPORT.PRIMARY_ACTIONS.PAY); }); + it('should not return PAY for expense report waiting for the cancelled payment to finish processing', async () => { + // Given a closed expense report whose cancelled payment is still being sent back to the payer + const report = createMock({ + reportID: REPORT_ID, + type: CONST.REPORT.TYPE.EXPENSE, + ownerAccountID: CURRENT_USER_ACCOUNT_ID, + statusNum: CONST.REPORT.STATUS_NUM.CLOSED, + total: -300, + isWaitingForCancelledReimbursement: true, + }); + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); + const policy = createMock({ + role: CONST.POLICY.ROLE.ADMIN, + }); + const transaction = createMock({ + reportID: `${REPORT_ID}`, + }); + + // When the primary action is calculated for the admin + const primaryAction = getReportPrimaryAction({ + rules: undefined, + currentUserLogin: CURRENT_USER_EMAIL, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + report, + ownerLogin: '', + chatReport, + reportTransactions: [transaction], + violations: {}, + bankAccountList: {}, + policy, + isChatReportArchived: false, + }); + + // Then PAY is not offered because the backend rejects paying until that money posts + expect(primaryAction).not.toBe(CONST.REPORT.PRIMARY_ACTIONS.PAY); + }); + it('should return PAY for non-reimburser payments admin in manual reimbursement mode when owner is payer', async () => { const ownerEmail = 'owner@manual-test.com'; const report = createMock({ diff --git a/tests/unit/ReportSecondaryActionUtilsTest.ts b/tests/unit/ReportSecondaryActionUtilsTest.ts index 16471032dbf1..09017ad2aa94 100644 --- a/tests/unit/ReportSecondaryActionUtilsTest.ts +++ b/tests/unit/ReportSecondaryActionUtilsTest.ts @@ -2222,6 +2222,42 @@ describe('getSecondaryAction', () => { expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(false); }); + it('does not include UNAPPROVE option while the cancelled payment is processing', () => { + // Given an approved expense report whose cancelled payment is still being sent back to the payer + const report = createMock({ + reportID: REPORT_ID, + type: CONST.REPORT.TYPE.EXPENSE, + ownerAccountID: EMPLOYEE_ACCOUNT_ID, + stateNum: CONST.REPORT.STATE_NUM.APPROVED, + statusNum: CONST.REPORT.STATUS_NUM.APPROVED, + managerID: EMPLOYEE_ACCOUNT_ID, + isWaitingForCancelledReimbursement: true, + }); + const policy = createMock({ + approver: EMPLOYEE_EMAIL, + role: CONST.POLICY.ROLE.ADMIN, + }); + + // When the secondary actions are calculated for the manager + const result = getSecondaryReportActions({ + currentUserLogin: EMPLOYEE_EMAIL, + currentUserAccountID: EMPLOYEE_ACCOUNT_ID, + submitterLogin: '', + report, + chatReport, + reportTransactions: [], + originalTransaction: createMock({}), + violations: {}, + bankAccountList: {}, + policy, + rules: undefined, + cardList: undefined, + }); + + // Then UNAPPROVE is not offered because the backend rejects unapproving until that money posts + expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE)).toBe(false); + }); + it('does not include UNAPPROVE option for non-admin on DEW policy', () => { // Given an approved expense report on a DEW policy where the current user is the manager but not an admin const report = createMock({