From 4adcdd8d9f67e4ab1ad91581e1ae38a51910d257 Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Wed, 4 Jun 2025 09:51:45 +0800 Subject: [PATCH 1/2] Fix: Remove amounts from forwarded copy --- src/languages/en.ts | 5 +- src/languages/es.ts | 6 +-- src/languages/params.ts | 3 -- src/libs/OptionsListUtils.ts | 6 +-- src/libs/ReportUtils.ts | 50 ++----------------- .../report/ContextMenu/ContextMenuActions.tsx | 6 +-- .../home/report/PureReportActionItem.tsx | 12 ++--- src/pages/home/report/ReportActionItem.tsx | 2 - 8 files changed, 14 insertions(+), 76 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index e1ff8dfafb00..80b8baef0a64 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -83,7 +83,6 @@ import type { FiltersAmountBetweenParams, FlightLayoverParams, FormattedMaxLengthParams, - ForwardedAmountParams, GoBackMessageParams, GoToRoomParams, ImportedTagsMessageParams, @@ -1078,8 +1077,8 @@ const translations = { approvedAmount: ({amount}: ApprovedAmountParams) => `approved ${amount}`, approvedMessage: `approved`, unapproved: `unapproved`, - automaticallyForwardedAmount: ({amount}: ForwardedAmountParams) => `approved ${amount} via workspace rules`, - forwardedAmount: ({amount}: ForwardedAmountParams) => `approved ${amount}`, + automaticallyForwarded: `approved via workspace rules`, + forwarded: `approved`, rejectedThisReport: 'rejected this report', waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `started settling up. Payment is on hold until ${submitterDisplayName} adds a bank account.`, adminCanceledRequest: ({manager}: AdminCanceledRequestParams) => `${manager ? `${manager}: ` : ''}canceled the payment`, diff --git a/src/languages/es.ts b/src/languages/es.ts index c27e94e46977..80091f10516c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -82,7 +82,6 @@ import type { FiltersAmountBetweenParams, FlightLayoverParams, FormattedMaxLengthParams, - ForwardedAmountParams, GoBackMessageParams, GoToRoomParams, ImportedTagsMessageParams, @@ -1073,9 +1072,8 @@ const translations = { approvedAmount: ({amount}: ApprovedAmountParams) => `aprobó ${amount}`, approvedMessage: `aprobado`, unapproved: `no aprobado`, - automaticallyForwardedAmount: ({amount}: ForwardedAmountParams) => - `aprobó ${amount} mediante reglas del espacio de trabajo`, - forwardedAmount: ({amount}: ForwardedAmountParams) => `aprobó ${amount}`, + automaticallyForwarded: `aprobó mediante reglas del espacio de trabajo`, + forwarded: `aprobó`, rejectedThisReport: 'rechazó este informe', waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `inició el pago, pero no se procesará hasta que ${submitterDisplayName} añada una cuenta bancaria`, adminCanceledRequest: ({manager}: AdminCanceledRequestParams) => `${manager ? `${manager}: ` : ''}canceló el pago`, diff --git a/src/languages/params.ts b/src/languages/params.ts index b988af96101d..98d606541096 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -153,8 +153,6 @@ type PayerPaidAmountParams = {payer?: string; amount: number | string}; type ApprovedAmountParams = {amount: number | string}; -type ForwardedAmountParams = {amount: number | string}; - type ManagerApprovedParams = {manager: string}; type ManagerApprovedAmountParams = {manager: string; amount: number | string}; @@ -795,7 +793,6 @@ export type { ElectronicFundsParams, EnterMagicCodeParams, FormattedMaxLengthParams, - ForwardedAmountParams, GoBackMessageParams, GoToRoomParams, HeldRequestParams, diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index d42586a216d7..5ae8fdac694f 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -95,7 +95,6 @@ import { getDisplayNameForParticipant, getDowngradeWorkspaceMessage, getIcons, - getIOUForwardedMessage, getMoneyRequestSpendBreakdown, getParticipantsAccountIDsForDisplay, getPolicyChangeMessage, @@ -103,7 +102,6 @@ import { getReimbursementDeQueuedOrCanceledActionMessage, getReimbursementQueuedActionMessage, getRejectedReportMessage, - getReportAutomaticallyForwardedMessage, getReportLastMessage, getReportName, getReportNotificationPreference, @@ -790,9 +788,9 @@ function getLastMessageTextForReport( } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) { const {automaticAction} = getOriginalMessage(lastReportAction) ?? {}; if (automaticAction) { - lastMessageTextFromReport = getReportAutomaticallyForwardedMessage(lastReportAction, reportID); + lastMessageTextFromReport = translateLocal('iou.automaticallyForwarded'); } else { - lastMessageTextFromReport = getIOUForwardedMessage(lastReportAction, report); + lastMessageTextFromReport = translateLocal('iou.forwarded'); } } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { lastMessageTextFromReport = getRejectedReportMessage(); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8a9c85cb0406..888352cc8af3 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4767,9 +4767,9 @@ function getReportNameInternal({ if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) { const {automaticAction} = getOriginalMessage(parentReportAction) ?? {}; if (automaticAction) { - return Parser.htmlToText(getReportAutomaticallyForwardedMessage(parentReportAction, reportID)); + return translateLocal('iou.automaticallyForwarded'); } - return getIOUForwardedMessage(parentReportAction, report, reports); + return translateLocal('iou.forwarded'); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { return getRejectedReportMessage(); @@ -5788,48 +5788,6 @@ function getFormattedAmount(reportAction: ReportAction, report?: Report | null) return formattedAmount; } -/** - * We pass the reportID as older FORWARDED actions do not have the amount & currency stored in the message - * so we retrieve the amount from the report instead - */ -function getReportAutomaticallyForwardedMessage(reportAction: ReportAction, reportOrID: OnyxInputOrEntry | string | SearchReport) { - const expenseReport = typeof reportOrID === 'string' ? getReport(reportOrID, allReports) : reportOrID; - const originalMessage = getOriginalMessage(reportAction) as OriginalMessageIOU; - let formattedAmount; - - // Older FORWARDED action might not have the amount stored in the original message, we'll fallback to getting the amount from the report instead. - if (originalMessage?.amount) { - formattedAmount = getFormattedAmount(reportAction, expenseReport); - } else { - formattedAmount = convertToDisplayString(getMoneyRequestSpendBreakdown(expenseReport).totalDisplaySpend, expenseReport?.currency); - } - - return translateLocal('iou.automaticallyForwardedAmount', {amount: formattedAmount}); -} - -/** - * We pass the reportID as older FORWARDED actions do not have the amount & currency stored in the message - * so we retrieve the amount from the report instead - */ -function getIOUForwardedMessage( - reportAction: ReportAction, - reportOrID: OnyxInputOrEntry | string | SearchReport, - reports?: SearchReport[], -) { - const expenseReport = typeof reportOrID === 'string' ? getReport(reportOrID, reports ?? allReports) : reportOrID; - const originalMessage = getOriginalMessage(reportAction) as OriginalMessageIOU; - let formattedAmount; - - // Older FORWARDED action might not have the amount stored in the original message, we'll fallback to getting the amount from the report instead. - if (originalMessage?.amount) { - formattedAmount = getFormattedAmount(reportAction, expenseReport); - } else { - formattedAmount = convertToDisplayString(getMoneyRequestSpendBreakdown(expenseReport, reports).totalDisplaySpend, expenseReport?.currency); - } - - return translateLocal('iou.forwardedAmount', {amount: formattedAmount}); -} - function getRejectedReportMessage() { return translateLocal('iou.rejectedThisReport'); } @@ -5922,7 +5880,7 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num iouMessage = `approved ${amount}`; break; case CONST.REPORT.ACTIONS.TYPE.FORWARDED: - iouMessage = translateLocal('iou.forwardedAmount', {amount}); + iouMessage = `approved ${amount}`; break; case CONST.REPORT.ACTIONS.TYPE.UNAPPROVED: iouMessage = `unapproved ${amount}`; @@ -10948,8 +10906,6 @@ export { prepareOnboardingOnyxData, getIOUReportActionDisplayMessage, getIOUReportActionMessage, - getReportAutomaticallyForwardedMessage, - getIOUForwardedMessage, getRejectedReportMessage, getWorkspaceNameUpdatedMessage, getDeletedTransactionMessage, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 96bbecddc053..dd1c49e1adae 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -86,14 +86,12 @@ import { getChildReportNotificationPreference as getChildReportNotificationPreferenceReportUtils, getDeletedTransactionMessage, getDowngradeWorkspaceMessage, - getIOUForwardedMessage, getIOUReportActionDisplayMessage, getOriginalReportID, getPolicyChangeMessage, getReimbursementDeQueuedOrCanceledActionMessage, getReimbursementQueuedActionMessage, getRejectedReportMessage, - getReportAutomaticallyForwardedMessage, getReportName, getReportPreviewMessage, getUpgradeWorkspaceMessage, @@ -575,9 +573,9 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) { const {automaticAction} = getOriginalMessage(reportAction) ?? {}; if (automaticAction) { - setClipboardMessage(getReportAutomaticallyForwardedMessage(reportAction, reportID)); + setClipboardMessage(translateLocal('iou.automaticallyForwarded')); } else { - Clipboard.setString(getIOUForwardedMessage(reportAction, reportID)); + Clipboard.setString(translateLocal('iou.forwarded')); } } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { const displayMessage = getRejectedReportMessage(); diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 0f4285c4b8d9..22374ef83d44 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -125,7 +125,6 @@ import { getDisplayNamesWithTooltips, getDowngradeWorkspaceMessage, getIconsForParticipants, - getIOUForwardedMessage, getMovedTransactionMessage, getPolicyChangeMessage, getRejectedReportMessage, @@ -331,9 +330,6 @@ type PureReportActionItemProps = { /** User payment card ID */ userBillingFundID?: number; - /** A message related to a report action that has been automatically forwarded */ - reportAutomaticallyForwardedMessage?: string; - /** Policies */ policies?: OnyxCollection; @@ -397,7 +393,6 @@ function PureReportActionItem({ clearAllRelatedReportActionErrors = () => {}, dismissTrackExpenseActionableWhisper = () => {}, userBillingFundID, - reportAutomaticallyForwardedMessage, policies, shouldShowBorder, }: PureReportActionItemProps) { @@ -1029,11 +1024,11 @@ function PureReportActionItem({ if (wasAutoForwarded) { children = ( - ${reportAutomaticallyForwardedMessage}`} /> + ${translate('iou.automaticallyForwarded')}`} /> ); } else { - children = ; + children = ; } } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) { children = ; @@ -1568,7 +1563,6 @@ export default memo(PureReportActionItem, (prevProps, nextProps) => { lodashIsEqual(prevProps.missingPaymentMethod, nextProps.missingPaymentMethod) && prevProps.reimbursementDeQueuedOrCanceledActionMessage === nextProps.reimbursementDeQueuedOrCanceledActionMessage && prevProps.modifiedExpenseMessage === nextProps.modifiedExpenseMessage && - prevProps.userBillingFundID === nextProps.userBillingFundID && - prevProps.reportAutomaticallyForwardedMessage === nextProps.reportAutomaticallyForwardedMessage + prevProps.userBillingFundID === nextProps.userBillingFundID ); }); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 34cfee29ac2d..c0d1bf0002e4 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -11,7 +11,6 @@ import { getIndicatedMissingPaymentMethod, getOriginalReportID, getReimbursementDeQueuedOrCanceledActionMessage, - getReportAutomaticallyForwardedMessage, getTransactionsWithReceipts, isArchivedNonExpenseReportWithID, isChatThread, @@ -102,7 +101,6 @@ function ReportActionItem({action, report, ...props}: PureReportActionItemProps) clearAllRelatedReportActionErrors={clearAllRelatedReportActionErrors} dismissTrackExpenseActionableWhisper={dismissTrackExpenseActionableWhisper} userBillingFundID={userBillingFundID} - reportAutomaticallyForwardedMessage={getReportAutomaticallyForwardedMessage(action as ReportAction, reportID)} /> ); } From b8002aa9c02213505da069429264444771db192d Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Wed, 4 Jun 2025 10:18:35 +0800 Subject: [PATCH 2/2] ESLint fix --- src/libs/ReportUtils.ts | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 888352cc8af3..6283a45340f4 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -11,13 +11,7 @@ import lodashMaxBy from 'lodash/maxBy'; import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {SvgProps} from 'react-native-svg'; -import type { - OriginalMessageChangePolicy, - OriginalMessageExportIntegration, - OriginalMessageIOU, - OriginalMessageModifiedExpense, - OriginalMessageMovedTransaction, -} from 'src/types/onyx/OriginalMessage'; +import type {OriginalMessageChangePolicy, OriginalMessageExportIntegration, OriginalMessageModifiedExpense, OriginalMessageMovedTransaction} from 'src/types/onyx/OriginalMessage'; import type {SetRequired, TupleToUnion, ValueOf} from 'type-fest'; import type {FileObject} from '@components/AttachmentModal'; import {FallbackAvatar, IntacctSquare, NetSuiteSquare, QBOSquare, XeroSquare} from '@components/Icon/Expensicons'; @@ -173,7 +167,6 @@ import { isActionableJoinRequestPending, isActionableTrackExpense, isActionOfType, - isApprovedAction, isApprovedOrSubmittedReportAction, isCardIssuedAction, isClosedAction, @@ -182,7 +175,6 @@ import { isDeletedAction, isDeletedParentAction, isExportIntegrationAction, - isForwardedAction, isIntegrationMessageAction, isMarkAsClosedAction, isModifiedExpenseAction, @@ -199,8 +191,6 @@ import { isRoomChangeLogAction, isSentMoneyReportAction, isSplitBillAction as isSplitBillReportAction, - isSubmittedAction, - isSubmittedAndClosedAction, isThreadParentMessage, isTrackExpenseAction, isTransactionThread, @@ -4742,8 +4732,6 @@ function getReportNameInternal({ reportNameValuePairs, policies, }: GetReportNameParams): string { - const reportID = report?.reportID; - let formattedName: string | undefined; let parentReportAction: OnyxEntry; if (parentReportActionParam) { @@ -5768,26 +5756,6 @@ function buildOptimisticEmptyReport(reportID: string, accountID: number, parentR return optimisticEmptyReport; } -function getFormattedAmount(reportAction: ReportAction, report?: Report | null) { - if ( - !isSubmittedAction(reportAction) && - !isForwardedAction(reportAction) && - !isApprovedAction(reportAction) && - !isUnapprovedAction(reportAction) && - !isSubmittedAndClosedAction(reportAction) && - !isMarkAsClosedAction(reportAction) - ) { - return ''; - } - const originalMessage = getOriginalMessage(reportAction); - - // Expense reports can have a negative amount and we need to display it as negative in the UI - // the amount found in originalMessage does not accurately track this so we need to use the total from the report instead - const amount = report && isExpenseReport(report) ? (report?.total ?? 0) * -1 : Math.abs(originalMessage?.amount ?? 0); - const formattedAmount = convertToDisplayString(amount, originalMessage?.currency); - return formattedAmount; -} - function getRejectedReportMessage() { return translateLocal('iou.rejectedThisReport'); }