From fd857e72213f76804c836e1a8901f705de907b5d Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Wed, 11 Oct 2023 20:11:05 +0300 Subject: [PATCH 01/22] Feat: update the report when a payment is refunded --- src/CONST.ts | 4 ++++ src/components/ReportActionItem/MoneyRequestPreview.js | 2 ++ src/languages/en.ts | 3 +++ src/languages/es.ts | 3 +++ src/languages/types.ts | 3 +++ src/pages/home/report/ReportActionItem.js | 6 ++++++ 6 files changed, 21 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 23957827d140..91942313fa47 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -486,6 +486,7 @@ const CONST = { IOU: 'IOU', MODIFIEDEXPENSE: 'MODIFIEDEXPENSE', REIMBURSEMENTQUEUED: 'REIMBURSEMENTQUEUED', + REIMBURSEMENTDEQUEUED: 'REIMBURSEMENTDEQUEUED', RENAMED: 'RENAMED', REPORTPREVIEW: 'REPORTPREVIEW', SUBMITTED: 'SUBMITTED', @@ -1118,6 +1119,9 @@ const CONST = { DOCX: 'docx', SVG: 'svg', }, + CANCEL_REASON: { + PAYMENT_EXPIRED: 'CANCEL_REASON_PAYMENT_EXPIRED' + }, }, GROWL: { diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 35215cadd15d..783c52c0553b 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -206,6 +206,8 @@ function MoneyRequestPreview(props) { message += ` • ${props.translate('iou.pending')}`; } else if (ReportUtils.isSettled(props.iouReport.reportID)) { message += ` • ${props.translate('iou.settledExpensify')}`; + } else if(props.iouReport.originalMessage.reason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + message += ` • ${props.translate('iou.canceled')}`; } return message; }; diff --git a/src/languages/en.ts b/src/languages/en.ts index 7133ed88579e..3f47db2ecffd 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -76,6 +76,7 @@ import type { TagSelectionParams, TranslationBase, WalletProgramParams, + CanceledRequestParams, } from './types'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; @@ -522,6 +523,7 @@ export default { pay: 'Pay', viewDetails: 'View details', pending: 'Pending', + canceled: 'Canceled', deleteReceipt: 'Delete receipt', receiptScanning: 'Receipt scan in progress…', receiptMissingDetails: 'Receipt missing details', @@ -545,6 +547,7 @@ export default { managerApproved: ({manager}: ManagerApprovedParams) => `${manager} approved:`, payerSettled: ({amount}: PayerSettledParams) => `paid ${amount}`, waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `started settling up, payment is held until ${submitterDisplayName} adds a bank account`, + canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) => `Canceled the ${amount} payment, because ${submitterDisplayName} did not enable their Expensify Wallet within 30 days`, settledAfterAddedBankAccount: ({submitterDisplayName, amount}: SettledAfterAddedBankAccountParams) => `${submitterDisplayName} added a bank account. The ${amount} payment has been made.`, paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer} paid ${amount} elsewhere`, diff --git a/src/languages/es.ts b/src/languages/es.ts index a98ddfaff7d0..db8e0d7c43c7 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -76,6 +76,7 @@ import type { TagSelectionParams, EnglishTranslation, WalletProgramParams, + CanceledRequestParams, } from './types'; /* eslint-disable max-len */ @@ -514,6 +515,7 @@ export default { pay: 'Pagar', viewDetails: 'Ver detalles', pending: 'Pendiente', + canceled: 'Canceled', deleteReceipt: 'Eliminar recibo', receiptScanning: 'Escaneo de recibo en curso…', receiptMissingDetails: 'Recibo con campos vacíos', @@ -537,6 +539,7 @@ export default { managerApproved: ({manager}: ManagerApprovedParams) => `${manager} aprobó:`, payerSettled: ({amount}: PayerSettledParams) => `pagó ${amount}`, waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `inicio el pago, pero no se procesará hasta que ${submitterDisplayName} añada una cuenta bancaria`, + canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) => `Canceled the ${amount} payment, because ${submitterDisplayName} did not enable their Expensify Wallet within 30 days`, settledAfterAddedBankAccount: ({submitterDisplayName, amount}: SettledAfterAddedBankAccountParams) => `${submitterDisplayName} añadió una cuenta bancaria. El pago de ${amount} se ha realizado.`, paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer} pagó ${amount} de otra forma`, diff --git a/src/languages/types.ts b/src/languages/types.ts index 3ee504ccddd7..b3ce20500f85 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -122,6 +122,8 @@ type PayerSettledParams = {amount: number}; type WaitingOnBankAccountParams = {submitterDisplayName: string}; +type CanceledRequestParams = {amount: string, submitterDisplayName: string} + type SettledAfterAddedBankAccountParams = {submitterDisplayName: string; amount: string}; type PaidElsewhereWithAmountParams = {payer: string; amount: string}; @@ -277,6 +279,7 @@ export type { ManagerApprovedParams, PayerSettledParams, WaitingOnBankAccountParams, + CanceledRequestParams, SettledAfterAddedBankAccountParams, PaidElsewhereWithAmountParams, PaidWithExpensifyWithAmountParams, diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index d0e84499a443..36c8476df976 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -70,6 +70,7 @@ import themeColors from '../../../styles/themes/default'; import ReportActionItemBasicMessage from './ReportActionItemBasicMessage'; import RenderHTML from '../../../components/RenderHTML'; import ReportAttachmentsContext from './ReportAttachmentsContext'; +import * as CurrencyUtils from "../../../libs/CurrencyUtils"; const propTypes = { ...windowDimensionsPropTypes, @@ -361,6 +362,11 @@ function ReportActionItem(props) { ) : null} ); + } else if(props.action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED) { + const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetailsList, [props.iouReport.ownerAccountID, 'displayName'], props.iouReport.ownerEmail); + const amount = CurrencyUtils.convertToDisplayString(props.iouReport.total, props.iouReport.currency); + + children = ; } else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) { children = ; } else { From 2b33b90d6da6399626bcaafac99dbaee4592a1b3 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Wed, 11 Oct 2023 20:49:27 +0300 Subject: [PATCH 02/22] run prettier --- src/CONST.ts | 2 +- src/components/ReportActionItem/MoneyRequestPreview.js | 2 +- src/languages/en.ts | 3 ++- src/languages/es.ts | 3 ++- src/languages/types.ts | 2 +- src/pages/home/report/ReportActionItem.js | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 91942313fa47..308d83766d93 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1120,7 +1120,7 @@ const CONST = { SVG: 'svg', }, CANCEL_REASON: { - PAYMENT_EXPIRED: 'CANCEL_REASON_PAYMENT_EXPIRED' + PAYMENT_EXPIRED: 'CANCEL_REASON_PAYMENT_EXPIRED', }, }, diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 783c52c0553b..a408041dbf5c 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -206,7 +206,7 @@ function MoneyRequestPreview(props) { message += ` • ${props.translate('iou.pending')}`; } else if (ReportUtils.isSettled(props.iouReport.reportID)) { message += ` • ${props.translate('iou.settledExpensify')}`; - } else if(props.iouReport.originalMessage.reason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + } else if (props.iouReport.originalMessage.reason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { message += ` • ${props.translate('iou.canceled')}`; } return message; diff --git a/src/languages/en.ts b/src/languages/en.ts index 3f47db2ecffd..e5ab33014b4a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -547,7 +547,8 @@ export default { managerApproved: ({manager}: ManagerApprovedParams) => `${manager} approved:`, payerSettled: ({amount}: PayerSettledParams) => `paid ${amount}`, waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `started settling up, payment is held until ${submitterDisplayName} adds a bank account`, - canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) => `Canceled the ${amount} payment, because ${submitterDisplayName} did not enable their Expensify Wallet within 30 days`, + canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) => + `Canceled the ${amount} payment, because ${submitterDisplayName} did not enable their Expensify Wallet within 30 days`, settledAfterAddedBankAccount: ({submitterDisplayName, amount}: SettledAfterAddedBankAccountParams) => `${submitterDisplayName} added a bank account. The ${amount} payment has been made.`, paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer} paid ${amount} elsewhere`, diff --git a/src/languages/es.ts b/src/languages/es.ts index db8e0d7c43c7..c88d6fb290ac 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -539,7 +539,8 @@ export default { managerApproved: ({manager}: ManagerApprovedParams) => `${manager} aprobó:`, payerSettled: ({amount}: PayerSettledParams) => `pagó ${amount}`, waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `inicio el pago, pero no se procesará hasta que ${submitterDisplayName} añada una cuenta bancaria`, - canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) => `Canceled the ${amount} payment, because ${submitterDisplayName} did not enable their Expensify Wallet within 30 days`, + canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) => + `Canceled the ${amount} payment, because ${submitterDisplayName} did not enable their Expensify Wallet within 30 days`, settledAfterAddedBankAccount: ({submitterDisplayName, amount}: SettledAfterAddedBankAccountParams) => `${submitterDisplayName} añadió una cuenta bancaria. El pago de ${amount} se ha realizado.`, paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer} pagó ${amount} de otra forma`, diff --git a/src/languages/types.ts b/src/languages/types.ts index b3ce20500f85..4ba148a7869d 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -122,7 +122,7 @@ type PayerSettledParams = {amount: number}; type WaitingOnBankAccountParams = {submitterDisplayName: string}; -type CanceledRequestParams = {amount: string, submitterDisplayName: string} +type CanceledRequestParams = {amount: string; submitterDisplayName: string}; type SettledAfterAddedBankAccountParams = {submitterDisplayName: string; amount: string}; diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 36c8476df976..5c52670fd37e 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -70,7 +70,7 @@ import themeColors from '../../../styles/themes/default'; import ReportActionItemBasicMessage from './ReportActionItemBasicMessage'; import RenderHTML from '../../../components/RenderHTML'; import ReportAttachmentsContext from './ReportAttachmentsContext'; -import * as CurrencyUtils from "../../../libs/CurrencyUtils"; +import * as CurrencyUtils from '../../../libs/CurrencyUtils'; const propTypes = { ...windowDimensionsPropTypes, @@ -362,7 +362,7 @@ function ReportActionItem(props) { ) : null} ); - } else if(props.action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED) { + } else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED) { const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetailsList, [props.iouReport.ownerAccountID, 'displayName'], props.iouReport.ownerEmail); const amount = CurrencyUtils.convertToDisplayString(props.iouReport.total, props.iouReport.currency); From 0aac629c63aede00570c19eef26e3275812c0b35 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Wed, 11 Oct 2023 23:44:42 +0300 Subject: [PATCH 03/22] prevent crash by checking key existence --- src/components/ReportActionItem/MoneyRequestPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index a408041dbf5c..fc294c3ffeda 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -206,7 +206,7 @@ function MoneyRequestPreview(props) { message += ` • ${props.translate('iou.pending')}`; } else if (ReportUtils.isSettled(props.iouReport.reportID)) { message += ` • ${props.translate('iou.settledExpensify')}`; - } else if (props.iouReport.originalMessage.reason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + } else if (props.iouReport.originalMessage && props.iouReport.originalMessage.reason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { message += ` • ${props.translate('iou.canceled')}`; } return message; From b7986d4975e834a3642655634bf9884b66285fcb Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Wed, 11 Oct 2023 23:57:24 +0300 Subject: [PATCH 04/22] Add es translations --- src/languages/es.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 500cc529304c..d0e5efa00c12 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -519,7 +519,7 @@ export default { pay: 'Pagar', viewDetails: 'Ver detalles', pending: 'Pendiente', - canceled: 'Canceled', + canceled: 'Canceló', posted: 'Contabilizado', deleteReceipt: 'Eliminar recibo', receiptScanning: 'Escaneo de recibo en curso…', @@ -545,7 +545,7 @@ export default { payerSettled: ({amount}: PayerSettledParams) => `pagó ${amount}`, waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `inicio el pago, pero no se procesará hasta que ${submitterDisplayName} añada una cuenta bancaria`, canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) => - `Canceled the ${amount} payment, because ${submitterDisplayName} did not enable their Expensify Wallet within 30 days`, + `Canceló el pago ${amount}, porque ${submitterDisplayName} no habilitó su billetera Expensify en un plazo de 30 días.`, settledAfterAddedBankAccount: ({submitterDisplayName, amount}: SettledAfterAddedBankAccountParams) => `${submitterDisplayName} añadió una cuenta bancaria. El pago de ${amount} se ha realizado.`, paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer} pagó ${amount} de otra forma`, From 444b732a645942f6fbc91d94ea2ec58f83d49f5a Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Thu, 12 Oct 2023 00:17:24 +0300 Subject: [PATCH 05/22] use report action value --- src/components/ReportActionItem/MoneyRequestPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index aa19c8536446..b557325e8505 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -216,7 +216,7 @@ function MoneyRequestPreview(props) { message += ` • ${props.translate('iou.approved')}`; } else if (props.iouReport.isWaitingOnBankAccount) { message += ` • ${props.translate('iou.pending')}`; - } else if (props.iouReport.originalMessage && props.iouReport.originalMessage.reason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + } else if (props.action.originalMessage && props.action.originalMessage.reason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { message += ` • ${props.translate('iou.canceled')}`; } return message; From 99d4202ea5fd271146a47f77b4459b1498a9a885 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 17 Oct 2023 17:44:47 +0300 Subject: [PATCH 06/22] use props.report value for amount and name --- src/pages/home/report/ReportActionItem.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index f51b0645cd7f..45621297ed98 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -363,8 +363,8 @@ function ReportActionItem(props) { ); } else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED) { - const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetailsList, [props.iouReport.ownerAccountID, 'displayName'], props.iouReport.ownerEmail); - const amount = CurrencyUtils.convertToDisplayString(props.iouReport.total, props.iouReport.currency); + const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetailsList, [props.report.ownerAccountID, 'displayName'], props.report.ownerEmail); + const amount = CurrencyUtils.convertToDisplayString(props.report.total, props.report.currency); children = ; } else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE) { From 839326e399ff4753f5c026ff96d81715c5ce826c Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Fri, 10 Nov 2023 19:08:07 +0300 Subject: [PATCH 07/22] update 'reason' to 'cancellationReason' --- src/components/ReportActionItem/MoneyRequestPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index f7c647fb4c86..c22b204dd80f 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -219,7 +219,7 @@ function MoneyRequestPreview(props) { message += ` • ${props.translate('iou.approved')}`; } else if (props.iouReport.isWaitingOnBankAccount) { message += ` • ${props.translate('iou.pending')}`; - } else if (props.action.originalMessage && props.action.originalMessage.reason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + } else if (props.action.originalMessage && props.action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { message += ` • ${props.translate('iou.canceled')}`; } return message; From f2c59f35b7f2e99005951a96e2f2c2b545fe518d Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Fri, 10 Nov 2023 19:15:11 +0300 Subject: [PATCH 08/22] remove usage of report.ownerEmail and add condition for canceled case --- src/components/ReportActionItem/MoneyRequestView.js | 6 ++++-- src/pages/home/report/ReportActionItem.js | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 4b69f14213a2..7130e3d41928 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -77,7 +77,7 @@ const defaultProps = { policyTags: {}, }; -function MoneyRequestView({report, betas, parentReport, policyCategories, shouldShowHorizontalRule, transaction, policyTags, policy}) { +function MoneyRequestView({report, betas, parentReport, policyCategories, shouldShowHorizontalRule, transaction, policyTags, policy, action}) { const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); const parentReportAction = ReportActionsUtils.getParentReportAction(report); @@ -136,7 +136,9 @@ function MoneyRequestView({report, betas, parentReport, policyCategories, should if (!isDistanceRequest) { amountDescription += ` • ${translate('iou.cash')}`; } - if (isSettled) { + if(props.action && props.action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + amountDescription += ` • ${translate('iou.canceled')}`; + } else if (isSettled) { amountDescription += ` • ${translate('iou.settledExpensify')}`; } else if (report.isWaitingOnBankAccount) { amountDescription += ` • ${translate('iou.pending')}`; diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index df56d38dc2dd..448e0ae166c9 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -415,7 +415,7 @@ function ReportActionItem(props) { ); } else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED) { - const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetailsList, [props.report.ownerAccountID, 'displayName'], props.report.ownerEmail); + const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails, [props.report.ownerAccountID, 'displayName']); const amount = CurrencyUtils.convertToDisplayString(props.report.total, props.report.currency); children = ; @@ -572,6 +572,7 @@ function ReportActionItem(props) { content = ( From 0b1f90b76f37a60097f3ea0f4139cca3c86f91d2 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Fri, 10 Nov 2023 19:20:33 +0300 Subject: [PATCH 09/22] fix lint --- src/components/ReportActionItem/MoneyRequestView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 7130e3d41928..68656c6f40fe 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -136,7 +136,7 @@ function MoneyRequestView({report, betas, parentReport, policyCategories, should if (!isDistanceRequest) { amountDescription += ` • ${translate('iou.cash')}`; } - if(props.action && props.action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + if(action && action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { amountDescription += ` • ${translate('iou.canceled')}`; } else if (isSettled) { amountDescription += ` • ${translate('iou.settledExpensify')}`; From a4013f10ce3981cf83583103006f05748ad1bfe5 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Fri, 10 Nov 2023 19:21:47 +0300 Subject: [PATCH 10/22] run prettier --- src/components/ReportActionItem/MoneyRequestView.js | 2 +- src/pages/home/report/ReportActionItem.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 68656c6f40fe..0df83a6c36c9 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -136,7 +136,7 @@ function MoneyRequestView({report, betas, parentReport, policyCategories, should if (!isDistanceRequest) { amountDescription += ` • ${translate('iou.cash')}`; } - if(action && action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + if (action && action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { amountDescription += ` • ${translate('iou.canceled')}`; } else if (isSettled) { amountDescription += ` • ${translate('iou.settledExpensify')}`; diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 448e0ae166c9..43526d7ee5c4 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -74,7 +74,7 @@ import ReportActionItemSingle from './ReportActionItemSingle'; import ReportActionItemThread from './ReportActionItemThread'; import reportActionPropTypes from './reportActionPropTypes'; import ReportAttachmentsContext from './ReportAttachmentsContext'; -import * as CurrencyUtils from '../../../libs/CurrencyUtils'; +import * as CurrencyUtils from '@libs/CurrencyUtils'; const propTypes = { ...windowDimensionsPropTypes, From 97d8c5eb14f6bf902535d23e9074dd29a44582b9 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Fri, 10 Nov 2023 19:26:18 +0300 Subject: [PATCH 11/22] lint! --- src/pages/home/report/ReportActionItem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 43526d7ee5c4..bbd368fa6734 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -58,6 +58,7 @@ import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import * as CurrencyUtils from '@libs/CurrencyUtils'; import AnimatedEmptyStateBackground from './AnimatedEmptyStateBackground'; import * as ContextMenuActions from './ContextMenu/ContextMenuActions'; import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu'; @@ -74,7 +75,6 @@ import ReportActionItemSingle from './ReportActionItemSingle'; import ReportActionItemThread from './ReportActionItemThread'; import reportActionPropTypes from './reportActionPropTypes'; import ReportAttachmentsContext from './ReportAttachmentsContext'; -import * as CurrencyUtils from '@libs/CurrencyUtils'; const propTypes = { ...windowDimensionsPropTypes, From 2f0af0c67c0a664d363bcb25559bf6c211f215fd Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Mon, 13 Nov 2023 12:51:30 +0300 Subject: [PATCH 12/22] fix crash --- src/components/ReportActionItem/MoneyRequestView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 0df83a6c36c9..b51a55082e0a 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -136,7 +136,7 @@ function MoneyRequestView({report, betas, parentReport, policyCategories, should if (!isDistanceRequest) { amountDescription += ` • ${translate('iou.cash')}`; } - if (action && action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + if (action && action.originalMessage && action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { amountDescription += ` • ${translate('iou.canceled')}`; } else if (isSettled) { amountDescription += ` • ${translate('iou.settledExpensify')}`; From ef72ec73c244a94611a892ed91edfab9b73669d0 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Mon, 13 Nov 2023 12:51:51 +0300 Subject: [PATCH 13/22] run prettier --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- src/pages/home/report/ReportActionItem.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 32143a9ae73a..2dcf373a3182 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -9,6 +9,7 @@ import type { BeginningOfChatHistoryAnnounceRoomPartOneParams, BeginningOfChatHistoryAnnounceRoomPartTwo, BeginningOfChatHistoryDomainRoomPartOneParams, + CanceledRequestParams, CharacterLimitParams, ConfirmThatParams, DateShouldBeAfterParams, @@ -78,7 +79,6 @@ import type { WelcomeToRoomParams, WeSentYouMagicSignInLinkParams, ZipCodeExampleFormatParams, - CanceledRequestParams, } from './types'; type StateValue = { diff --git a/src/languages/es.ts b/src/languages/es.ts index 7e3e7d89fdb5..5486898ca63b 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -8,6 +8,7 @@ import type { BeginningOfChatHistoryAnnounceRoomPartOneParams, BeginningOfChatHistoryAnnounceRoomPartTwo, BeginningOfChatHistoryDomainRoomPartOneParams, + CanceledRequestParams, CharacterLimitParams, ConfirmThatParams, DateShouldBeAfterParams, @@ -77,7 +78,6 @@ import type { WelcomeToRoomParams, WeSentYouMagicSignInLinkParams, ZipCodeExampleFormatParams, - CanceledRequestParams, } from './types'; /* eslint-disable max-len */ diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index bbd368fa6734..031aebdb3512 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -34,6 +34,7 @@ import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withW import usePrevious from '@hooks/usePrevious'; import compose from '@libs/compose'; import ControlSelection from '@libs/ControlSelection'; +import * as CurrencyUtils from '@libs/CurrencyUtils'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import focusTextInputAfterAnimation from '@libs/focusTextInputAfterAnimation'; import Navigation from '@libs/Navigation/Navigation'; @@ -58,7 +59,6 @@ import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import * as CurrencyUtils from '@libs/CurrencyUtils'; import AnimatedEmptyStateBackground from './AnimatedEmptyStateBackground'; import * as ContextMenuActions from './ContextMenu/ContextMenuActions'; import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu'; From 6b785819b0bea0bea261eeb06487ecce5fddf08b Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 28 Nov 2023 12:32:06 +0300 Subject: [PATCH 14/22] add type in OriginalMessage for Dequeued action --- src/types/onyx/OriginalMessage.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 014cd67a9a2a..34b908e7ed56 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -178,6 +178,11 @@ type OriginalMessageReimbursementQueued = { originalMessage: unknown; }; +type OriginalMessageReimbursementDequeued = { + actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED; + originalMessage: unknown; +}; + type OriginalMessage = | OriginalMessageApproved | OriginalMessageIOU @@ -192,7 +197,8 @@ type OriginalMessage = | OriginalMessagePolicyChangeLog | OriginalMessagePolicyTask | OriginalMessageModifiedExpense - | OriginalMessageReimbursementQueued; + | OriginalMessageReimbursementQueued + | OriginalMessageReimbursementDequeued; export default OriginalMessage; export type {ChronosOOOEvent, Decision, Reaction, ActionName}; From 899ee0a44dab710ab01d92bd5773a93fddd894fe Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 28 Nov 2023 12:37:33 +0300 Subject: [PATCH 15/22] update report preview based on dequeued action --- src/components/ReportActionItem/MoneyRequestPreview.js | 5 +++-- src/components/ReportActionItem/MoneyRequestView.js | 5 +++-- src/libs/ReportActionsUtils.ts | 10 ++++++++++ src/pages/home/report/ReportActionItem.js | 1 - 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index c22b204dd80f..ba9f7f1b256c 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -166,6 +166,7 @@ function MoneyRequestPreview(props) { const isDistanceRequest = TransactionUtils.isDistanceRequest(props.transaction); const isExpensifyCardTransaction = TransactionUtils.isExpensifyCardTransaction(props.transaction); const isSettled = ReportUtils.isSettled(props.iouReport.reportID); + const isCancelled = ReportActionsUtils.isReimbursementDeQueuedAction(props.iouReport.reportID); const isDeleted = lodashGet(props.action, 'pendingAction', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; // Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan @@ -219,7 +220,7 @@ function MoneyRequestPreview(props) { message += ` • ${props.translate('iou.approved')}`; } else if (props.iouReport.isWaitingOnBankAccount) { message += ` • ${props.translate('iou.pending')}`; - } else if (props.action.originalMessage && props.action.originalMessage.cancellationReason === CONST.IOU.CANCEL_REASON.PAYMENT_EXPIRED) { + } else if (isCancelled) { message += ` • ${props.translate('iou.canceled')}`; } return message; @@ -279,7 +280,7 @@ function MoneyRequestPreview(props) { - {getPreviewHeaderText() + (isSettled ? ` • ${getSettledMessage()}` : '')} + {getPreviewHeaderText() + (isSettled && !isCancelled ? ` • ${getSettledMessage()}` : '')} {hasFieldErrors && ( ) { return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED; } +function isReimbursementDeQueuedAction(reportID: string): boolean { + if (!allReportActions) { + return false + } + + const reportAction = Object.values(allReportActions[`${reportID}`] ?? {}); + return reportAction.some(action => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED); +} + /** * Returns whether the comment is a thread parent message/the first message in a thread */ @@ -657,4 +666,5 @@ export { shouldReportActionBeVisible, shouldReportActionBeVisibleAsLastAction, getFirstVisibleReportActionID, + isReimbursementDeQueuedAction }; diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 031aebdb3512..f5322aa9aabb 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -572,7 +572,6 @@ function ReportActionItem(props) { content = ( From 40b9818f640c9900a9ee139102e7848bf0c3f020 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 28 Nov 2023 13:14:14 +0300 Subject: [PATCH 16/22] missed condition --- src/components/ReportActionItem/MoneyRequestView.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 1448dec82bc6..a204b9d89d27 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -134,6 +134,9 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor if (TransactionUtils.isPending(transaction)) { amountDescription += ` • ${translate('iou.pending')}`; } + if(isCancelled) { + amountDescription += ` • ${translate('iou.canceled')}`; + } } else { if (!isDistanceRequest) { amountDescription += ` • ${translate('iou.cash')}`; From 8cccd753054d19641c45c1cfd40f5b4c18f26341 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 28 Nov 2023 13:30:51 +0300 Subject: [PATCH 17/22] run prettier --- src/components/ReportActionItem/MoneyRequestView.js | 4 ++-- src/libs/ReportActionsUtils.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index a204b9d89d27..2599f348be71 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -134,14 +134,14 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor if (TransactionUtils.isPending(transaction)) { amountDescription += ` • ${translate('iou.pending')}`; } - if(isCancelled) { + if (isCancelled) { amountDescription += ` • ${translate('iou.canceled')}`; } } else { if (!isDistanceRequest) { amountDescription += ` • ${translate('iou.cash')}`; } - if(isCancelled) { + if (isCancelled) { amountDescription += ` • ${translate('iou.canceled')}`; } else if (isSettled) { amountDescription += ` • ${translate('iou.settledExpensify')}`; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index c05b6de631ca..99055f55af29 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -111,11 +111,11 @@ function isChannelLogMemberAction(reportAction: OnyxEntry) { function isReimbursementDeQueuedAction(reportID: string): boolean { if (!allReportActions) { - return false + return false; } const reportAction = Object.values(allReportActions[`${reportID}`] ?? {}); - return reportAction.some(action => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED); + return reportAction.some((action) => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED); } /** @@ -707,7 +707,7 @@ export { hasRequestFromCurrentAccount, getFirstVisibleReportActionID, isChannelLogMemberAction, - isReimbursementDeQueuedAction + isReimbursementDeQueuedAction, }; export type {LastVisibleMessage}; From d5c4dbeb4c0cb0e6bff1177659a1b7f24f6b9d0d Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 28 Nov 2023 13:39:19 +0300 Subject: [PATCH 18/22] add condition to handle canceled case --- src/libs/ReportUtils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index d93661778b83..bb9f1598630f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1684,6 +1684,10 @@ function getMoneyRequestReportName(report: OnyxEntry, policy: OnyxEntry< return `${payerPaidAmountMessage} • ${Localize.translateLocal('iou.pending')}`; } + if(report?.reportID && ReportActionsUtils.isReimbursementDeQueuedAction(report.reportID)) { + return `${payerPaidAmountMessage} • ${Localize.translateLocal('iou.canceled')}`; + } + if (hasNonReimbursableTransactions(report?.reportID)) { return Localize.translateLocal('iou.payerSpentAmount', {payer: payerName, amount: formattedAmount}); } From 30f43e41c874b2a36b104dfb34741080e52b1c74 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 28 Nov 2023 13:57:06 +0300 Subject: [PATCH 19/22] lint! --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index bb9f1598630f..e8354c16b547 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1684,7 +1684,7 @@ function getMoneyRequestReportName(report: OnyxEntry, policy: OnyxEntry< return `${payerPaidAmountMessage} • ${Localize.translateLocal('iou.pending')}`; } - if(report?.reportID && ReportActionsUtils.isReimbursementDeQueuedAction(report.reportID)) { + if (report?.reportID && ReportActionsUtils.isReimbursementDeQueuedAction(report.reportID)) { return `${payerPaidAmountMessage} • ${Localize.translateLocal('iou.canceled')}`; } From 2bbd0ef46159a4e4a8af3dff40b0c94a1a42fe10 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 28 Nov 2023 16:36:38 +0300 Subject: [PATCH 20/22] fix LHN last message text preview --- .../ReportActionItem/MoneyRequestPreview.js | 2 +- src/components/ReportActionItem/MoneyRequestView.js | 2 +- src/libs/OptionsListUtils.js | 2 ++ src/libs/ReportActionsUtils.ts | 10 +++++++++- src/libs/ReportUtils.ts | 13 ++++++++++++- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 4b333359f38b..09baa9322ff4 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -167,7 +167,7 @@ function MoneyRequestPreview(props) { const isDistanceRequest = TransactionUtils.isDistanceRequest(props.transaction); const isExpensifyCardTransaction = TransactionUtils.isExpensifyCardTransaction(props.transaction); const isSettled = ReportUtils.isSettled(props.iouReport.reportID); - const isCancelled = ReportActionsUtils.isReimbursementDeQueuedAction(props.iouReport.reportID); + const isCancelled = ReportActionsUtils.isReimbursementDeQueued(props.iouReport.reportID); const isDeleted = lodashGet(props.action, 'pendingAction', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; // Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 2599f348be71..2674b332f949 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -109,7 +109,7 @@ function MoneyRequestView({report, parentReport, policyCategories, shouldShowHor // Flags for allowing or disallowing editing a money request const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID); - const isCancelled = ReportActionsUtils.isReimbursementDeQueuedAction(moneyRequestReport.reportID); + const isCancelled = ReportActionsUtils.isReimbursementDeQueued(moneyRequestReport.reportID); const canEdit = ReportUtils.canEditMoneyRequest(parentReportAction); const canEditAmount = canEdit && !isSettled && !isCardTransaction; diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index c616587c3983..e3b6ec77380e 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -397,6 +397,8 @@ function getLastMessageTextForReport(report) { lastMessageTextFromReport = ReportUtils.getReportPreviewMessage(iouReport, lastIOUMoneyReport, true, ReportUtils.isChatReport(report)); } else if (ReportActionUtils.isReimbursementQueuedAction(lastReportAction)) { lastMessageTextFromReport = ReportUtils.getReimbursementQueuedActionMessage(lastReportAction, report); + } else if (ReportActionUtils.isReimbursementDeQueuedAction(lastReportAction)) { + lastMessageTextFromReport = ReportUtils.getReimbursementDeQueuedActionMessage(report); } else if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) { lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction); } else if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml, translationKey: report.lastMessageTranslationKey})) { diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 99055f55af29..dd6e70033571 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -109,7 +109,10 @@ function isChannelLogMemberAction(reportAction: OnyxEntry) { ); } -function isReimbursementDeQueuedAction(reportID: string): boolean { +/** + * Returns whether the report is dequeued only using reportID + */ +function isReimbursementDeQueued(reportID: string): boolean { if (!allReportActions) { return false; } @@ -118,6 +121,10 @@ function isReimbursementDeQueuedAction(reportID: string): boolean { return reportAction.some((action) => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED); } +function isReimbursementDeQueuedAction(reportAction: OnyxEntry): boolean { + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED; +} + /** * Returns whether the comment is a thread parent message/the first message in a thread */ @@ -707,6 +714,7 @@ export { hasRequestFromCurrentAccount, getFirstVisibleReportActionID, isChannelLogMemberAction, + isReimbursementDeQueued, isReimbursementDeQueuedAction, }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e8354c16b547..8c9afeb6b280 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1480,6 +1480,16 @@ function getReimbursementQueuedActionMessage(reportAction: OnyxEntry): string { + const submitterDisplayName = getDisplayNameForParticipant(report?.ownerAccountID, true) ?? ''; + const amount = CurrencyUtils.convertToDisplayString(report?.total ?? 0, report?.currency); + + return Localize.translateLocal('iou.canceledRequest', {submitterDisplayName, amount}); +} + /** * Returns the last visible message for a given report after considering the given optimistic actions * @@ -1684,7 +1694,7 @@ function getMoneyRequestReportName(report: OnyxEntry, policy: OnyxEntry< return `${payerPaidAmountMessage} • ${Localize.translateLocal('iou.pending')}`; } - if (report?.reportID && ReportActionsUtils.isReimbursementDeQueuedAction(report.reportID)) { + if (report?.reportID && ReportActionsUtils.isReimbursementDeQueued(report.reportID)) { return `${payerPaidAmountMessage} • ${Localize.translateLocal('iou.canceled')}`; } @@ -4380,6 +4390,7 @@ export { shouldUseFullTitleToDisplay, parseReportRouteParams, getReimbursementQueuedActionMessage, + getReimbursementDeQueuedActionMessage, getPersonalDetailsForAccountID, getChannelLogMemberMessage, getRoom, From 555ddcb309e218bf619dd308f6b7e515081c519c Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Thu, 30 Nov 2023 11:45:17 +0300 Subject: [PATCH 21/22] use isCancelledIOU and remove redundant function --- .../ReportActionItem/MoneyRequestPreview.js | 5 ++--- src/components/ReportActionItem/MoneyRequestView.js | 2 +- src/libs/ReportActionsUtils.ts | 13 ------------- src/libs/ReportUtils.ts | 2 +- src/types/onyx/Report.ts | 3 +++ 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 09baa9322ff4..1855152ef640 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -167,7 +167,6 @@ function MoneyRequestPreview(props) { const isDistanceRequest = TransactionUtils.isDistanceRequest(props.transaction); const isExpensifyCardTransaction = TransactionUtils.isExpensifyCardTransaction(props.transaction); const isSettled = ReportUtils.isSettled(props.iouReport.reportID); - const isCancelled = ReportActionsUtils.isReimbursementDeQueued(props.iouReport.reportID); const isDeleted = lodashGet(props.action, 'pendingAction', null) === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; // Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan @@ -221,7 +220,7 @@ function MoneyRequestPreview(props) { message += ` • ${props.translate('iou.approved')}`; } else if (props.iouReport.isWaitingOnBankAccount) { message += ` • ${props.translate('iou.pending')}`; - } else if (isCancelled) { + } else if (props.iouReport.isCancelledIOU) { message += ` • ${props.translate('iou.canceled')}`; } return message; @@ -283,7 +282,7 @@ function MoneyRequestPreview(props) { - {getPreviewHeaderText() + (isSettled && !isCancelled ? ` • ${getSettledMessage()}` : '')} + {getPreviewHeaderText() + (isSettled && !props.iouReport.isCancelledIOU ? ` • ${getSettledMessage()}` : '')} {hasFieldErrors && ( ) { ); } -/** - * Returns whether the report is dequeued only using reportID - */ -function isReimbursementDeQueued(reportID: string): boolean { - if (!allReportActions) { - return false; - } - - const reportAction = Object.values(allReportActions[`${reportID}`] ?? {}); - return reportAction.some((action) => action?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED); -} - function isReimbursementDeQueuedAction(reportAction: OnyxEntry): boolean { return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTDEQUEUED; } @@ -714,7 +702,6 @@ export { hasRequestFromCurrentAccount, getFirstVisibleReportActionID, isChannelLogMemberAction, - isReimbursementDeQueued, isReimbursementDeQueuedAction, }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8c9afeb6b280..b6c7b3a34c33 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1694,7 +1694,7 @@ function getMoneyRequestReportName(report: OnyxEntry, policy: OnyxEntry< return `${payerPaidAmountMessage} • ${Localize.translateLocal('iou.pending')}`; } - if (report?.reportID && ReportActionsUtils.isReimbursementDeQueued(report.reportID)) { + if (report?.isCancelledIOU) { return `${payerPaidAmountMessage} • ${Localize.translateLocal('iou.canceled')}`; } diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 81a92c4bf603..d656f79a6a71 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -118,6 +118,9 @@ type Report = { /** Whether the report is waiting on a bank account */ isWaitingOnBankAccount?: boolean; + /** Whether the report is cancelled */ + isCancelledIOU?: boolean; + /** Whether the last message was deleted */ isLastMessageDeletedParentAction?: boolean; From 75ad8c4aabb0a4accafc7da09d10bb15b029d4b5 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Thu, 30 Nov 2023 11:50:51 +0300 Subject: [PATCH 22/22] run prettier --- src/types/onyx/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index d656f79a6a71..418607a4e9b4 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -119,7 +119,7 @@ type Report = { isWaitingOnBankAccount?: boolean; /** Whether the report is cancelled */ - isCancelledIOU?: boolean; + isCancelledIOU?: boolean; /** Whether the last message was deleted */ isLastMessageDeletedParentAction?: boolean;