From cf9bd191d9050e1aca4c5a2e129dd30dc9dd0cf7 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 14 Jul 2025 12:54:15 -0600 Subject: [PATCH] Revert "[CP Staging] fix: regressions after pay button standardization" --- src/components/KYCWall/BaseKYCWall.tsx | 2 +- src/components/SettlementButton/index.tsx | 8 +++--- src/languages/params.ts | 4 +-- src/libs/ReportUtils.ts | 30 ++++++++++------------- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.tsx b/src/components/KYCWall/BaseKYCWall.tsx index 70e5bcab42297..06e5fc2bcaa67 100644 --- a/src/components/KYCWall/BaseKYCWall.tsx +++ b/src/components/KYCWall/BaseKYCWall.tsx @@ -228,7 +228,7 @@ function KYCWall({ } // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if ((paymentMethod || policy) && !hasActivatedWallet) { + if (paymentMethod || policy) { setShouldShowAddPaymentMenu(false); selectPaymentMethod(paymentMethod, policy); return; diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index 41564a5e83560..a181eec00ebca 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -129,7 +129,7 @@ function SettlementButton({ const hasMultiplePolicies = !isExpenseReport && activeAdminPolicies.length > 1; const lastPaymentMethodRef = useRef(lastPaymentMethod); const formattedPaymentMethods = formatPaymentMethods(bankAccountList, fundList, styles); - const hasIntentToPay = ((formattedPaymentMethods.length === 1 && isIOUReport(iouReport)) || !!policy?.achAccount) && !lastPaymentMethod; + const hasIntentToPay = formattedPaymentMethods.length === 1 && !lastPaymentMethod; useEffect(() => { if (isLoadingLastPaymentMethod) { @@ -268,7 +268,7 @@ function SettlementButton({ if (personalBankAccountList.length && canUsePersonalBankAccount) { buttonOptions.push({ text: translate('iou.settleWallet', {formattedAmount: ''}), - value: CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT, + value: CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT, icon: Expensicons.Wallet, }); } else if (canUsePersonalBankAccount) { @@ -299,7 +299,7 @@ function SettlementButton({ activeAdminPolicies.forEach((activePolicy) => { const policyName = activePolicy.name; buttonOptions.push({ - text: translate('iou.payWithPolicy', {policyName: truncate(policyName, {length: CONST.ADDITIONAL_ALLOWED_CHARACTERS}), formattedAmount: ''}), + text: translate('iou.payWithPolicy', {policyName: truncate(policyName, {length: 20}), formattedAmount: ''}), icon: Expensicons.Building, value: activePolicy.id, shouldUpdateSelectedIndex: false, @@ -541,7 +541,7 @@ function SettlementButton({ }; const customText = getCustomText(); - const secondaryText = truncate(getSecondaryText(), {length: CONST.FORM_CHARACTER_LIMIT}); + const secondaryText = getSecondaryText(); const defaultSelectedIndex = paymentButtonOptions.findIndex((paymentOption) => { if (lastPaymentMethod === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) { diff --git a/src/languages/params.ts b/src/languages/params.ts index 061c4cd7a455d..e03fb943cbf45 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -142,8 +142,8 @@ type WorkspacesListRouteParams = { }; type BusinessBankAccountParams = { - amount?: string; - last4Digits?: string; + amount: string; + last4Digits: string; }; type WorkspaceRouteParams = { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index fd3786c4c663b..531b01c83cf05 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4566,7 +4566,7 @@ function getReportPreviewMessage( } const containsNonReimbursable = hasNonReimbursableTransactions(report.reportID); - const {totalDisplaySpend: totalAmount} = getMoneyRequestSpendBreakdown(report); + const {totalDisplaySpend: totalAmount, reimbursableSpend} = getMoneyRequestSpendBreakdown(report); const parentReport = getParentReport(report); const policyName = getPolicyName({report: parentReport ?? report, policy}); @@ -4600,6 +4600,7 @@ function getReportPreviewMessage( // Show Paid preview message if it's settled or if the amount is paid & stuck at receivers end for only chat reports. if (isSettled(report.reportID) || (report.isWaitingOnBankAccount && isPreviewMessageForParentChatReport)) { + const formattedReimbursableAmount = convertToDisplayString(reimbursableSpend, report.currency); // A settled report preview message can come in three formats "paid ... elsewhere" or "paid ... with Expensify" let translatePhraseKey: TranslationPaths = 'iou.paidElsewhere'; if (isPreviewMessageForParentChatReport) { @@ -4625,7 +4626,7 @@ function getReportPreviewMessage( const payerDisplayName = isPreviewMessageForParentChatReport ? payerName : actualPayerName; return translateLocal(translatePhraseKey, { - amount: '', + amount: formattedReimbursableAmount, payer: payerDisplayName ?? '', last4Digits: reportPolicy?.achAccount?.accountNumber?.slice(-4) ?? '', }); @@ -5140,20 +5141,11 @@ function getReportNameInternal({ if (isMoneyRequestAction(parentReportAction)) { const originalMessage = getOriginalMessage(parentReportAction); - const reportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]; - const last4Digits = reportPolicy?.achAccount?.accountNumber.slice(-4) ?? ''; - if (originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) { if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) { return translateLocal('iou.paidElsewhere'); } - if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.VBBA) { - if (originalMessage.automaticAction) { - return translateLocal('iou.automaticallyPaidWithBusinessBankAccount', {last4Digits}); - } - return translateLocal('iou.businessBankAccount', {last4Digits}); - } - if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) { + if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.VBBA || originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) { if (originalMessage.automaticAction) { return translateLocal('iou.automaticallyPaidWithExpensify'); } @@ -9219,6 +9211,12 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry, let translationKey: TranslationPaths; if (originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) { + // The `REPORT_ACTION_TYPE.PAY` action type is used for both fulfilling existing requests and sending money. To + // differentiate between these two scenarios, we check if the `originalMessage` contains the `IOUDetails` + // property. If it does, it indicates that this is a 'Pay someone' action. + const {amount, currency} = originalMessage?.IOUDetails ?? originalMessage ?? {}; + const formattedAmount = convertToDisplayString(Math.abs(amount), currency) ?? ''; + const reportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]; const last4Digits = reportPolicy?.achAccount?.accountNumber.slice(-4) ?? ''; @@ -9229,13 +9227,11 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry, case CONST.IOU.PAYMENT_TYPE.EXPENSIFY: case CONST.IOU.PAYMENT_TYPE.VBBA: if (isInvoice) { - return translateLocal(payAsBusiness ? 'iou.settleInvoiceBusiness' : 'iou.settleInvoicePersonal', {amount: '', last4Digits}); + return translateLocal(payAsBusiness ? 'iou.settleInvoiceBusiness' : 'iou.settleInvoicePersonal', {amount: formattedAmount, last4Digits}); } translationKey = 'iou.businessBankAccount'; - if (automaticAction && originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) { + if (automaticAction) { translationKey = 'iou.automaticallyPaidWithExpensify'; - } else { - translationKey = 'iou.automaticallyPaidWithBusinessBankAccount'; } break; default: @@ -9243,7 +9239,7 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry, break; } - return translateLocal(translationKey, {amount: '', payer: '', last4Digits}); + return translateLocal(translationKey, {amount: formattedAmount, payer: '', last4Digits}); } const amount = getTransactionAmount(transaction, !isEmptyObject(iouReport) && isExpenseReport(iouReport)) ?? 0;