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
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 12 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `Warten, bis die Zahlung abgeschlossen ist${formattedETA}.`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
12 changes: 12 additions & 0 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2229,6 +2229,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `Αναμονή για την ολοκλήρωση της πληρωμής${formattedETA}.`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
13 changes: 13 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
7 changes: 7 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,13 @@ const translations: TranslationDeepObject<typeof en> = {
}
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 <strong>ti mismo</strong>. Aprobar tus propios informes está <strong>prohibido</strong> 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) => {
Expand Down
12 changes: 12 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `En attente de la finalisation du paiement${formattedETA}.`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
12 changes: 12 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `In attesa che il pagamento venga completato${formattedETA}.`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
12 changes: 12 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `支払いの完了を待機しています${formattedETA}。`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
12 changes: 12 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2175,6 +2175,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `Wachten tot de betaling is voltooid${formattedETA}.`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
12 changes: 12 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2211,6 +2211,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `Oczekiwanie na zakończenie płatności${formattedETA}.`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
12 changes: 12 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `Aguardando o pagamento ser concluído${formattedETA}.`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
12 changes: 12 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,18 @@ const translations: TranslationDeepObject<typeof en> = {
}
return `正在等待付款完成${formattedETA}。`;
},
[CONST.NEXT_STEP.MESSAGE_KEY.WAITING_FOR_CANCELLED_REIMBURSEMENT]: (
_actor: string,
_actorType: ValueOf<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
eta?: string,
etaType?: ValueOf<typeof CONST.NEXT_STEP.ETA_TYPE>,
) => {
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<typeof CONST.NEXT_STEP.ACTOR_TYPE>,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ReportPreviewActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
isInvoiceReport,
isIOUReport,
isOpenReport,
isPayBlockedByArchivedState,
isPayBlocked,
isPayer,
isProcessingReport,
isReportApproved,
Expand Down Expand Up @@ -136,7 +136,7 @@ function canPay(
) {
const isExpense = isExpenseReport(report);

if (isPayBlockedByArchivedState(report, policy, isReportArchived)) {
if (isPayBlocked(report, policy, isReportArchived)) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/ReportPrimaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
isInvoiceReport as isInvoiceReportUtils,
isIOUReport as isIOUReportUtils,
isOpenReport as isOpenReportUtils,
isPayBlockedByArchivedState,
isPayBlocked,
isPayer,
isProcessingReport as isProcessingReportUtils,
isReportApproved as isReportApprovedUtils,
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportSecondaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 7 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3306,7 +3306,7 @@ function canIOUBePaid(
) {
const iouSettled = isSettled(iouReport);

if (isEmptyObject(iouReport)) {
if (isEmptyObject(iouReport) || iouReport.isWaitingForCancelledReimbursement) {
return false;
}

Expand Down Expand Up @@ -14505,6 +14505,11 @@ function isPayBlockedByArchivedState(report: OnyxInputOrEntry<Report>, 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<Report>, policy: OnyxInputOrEntry<Policy>, isReportOrChatArchived: boolean): boolean {
return isPayBlockedByArchivedState(report, policy, isReportOrChatArchived) || !!report?.isWaitingForCancelledReimbursement;
}

function hasReportBeenReopened(report: OnyxEntry<Report>, reportActions?: OnyxEntry<ReportActions> | ReportAction[]): boolean {
if (report?.hasReportBeenReopened !== undefined) {
return report.hasReportBeenReopened;
Expand Down Expand Up @@ -15553,7 +15558,7 @@ export {
pushTransactionAutoSelectionsOnyxData,
navigateOnDeleteExpense,
canRejectReportAction,
isPayBlockedByArchivedState,
isPayBlocked,
hasReportBeenRejectedToSubmitter,
hasReportBeenReopened,
hasReportBeenRetracted,
Expand Down
1 change: 1 addition & 0 deletions src/selectors/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ function getStableReportSelector(report: OnyxEntry<Report>) {
errors: report.errors,
isWaitingOnBankAccount: report.isWaitingOnBankAccount,
canCancelReimbursement: report.canCancelReimbursement,
isWaitingForCancelledReimbursement: report.isWaitingForCancelledReimbursement,
isCancelledIOU: report.isCancelledIOU,
hasReportBeenRetracted: report.hasReportBeenRetracted,
hasReportBeenReopened: report.hasReportBeenReopened,
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/types/utils/whitelistedReportKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback<
errors: unknown;
isWaitingOnBankAccount: unknown;
canCancelReimbursement: unknown;
isWaitingForCancelledReimbursement: unknown;
isCancelledIOU: unknown;
hasReportBeenRetracted: unknown;
hasReportBeenReopened: unknown;
Expand Down
37 changes: 37 additions & 0 deletions tests/unit/ReportPrimaryActionUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Report>({
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<Policy>({
role: CONST.POLICY.ROLE.ADMIN,
});
const transaction = createMock<Transaction>({
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<Report>({
Expand Down
Loading
Loading