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
5 changes: 2 additions & 3 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ import type {
FiltersAmountBetweenParams,
FlightLayoverParams,
FormattedMaxLengthParams,
ForwardedAmountParams,
GoBackMessageParams,
GoToRoomParams,
ImportedTagsMessageParams,
Expand Down Expand Up @@ -1078,8 +1077,8 @@ const translations = {
approvedAmount: ({amount}: ApprovedAmountParams) => `approved ${amount}`,
approvedMessage: `approved`,
unapproved: `unapproved`,
automaticallyForwardedAmount: ({amount}: ForwardedAmountParams) => `approved ${amount} via <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">workspace rules</a>`,
forwardedAmount: ({amount}: ForwardedAmountParams) => `approved ${amount}`,
automaticallyForwarded: `approved via <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">workspace rules</a>`,
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`,
Expand Down
6 changes: 2 additions & 4 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ import type {
FiltersAmountBetweenParams,
FlightLayoverParams,
FormattedMaxLengthParams,
ForwardedAmountParams,
GoBackMessageParams,
GoToRoomParams,
ImportedTagsMessageParams,
Expand Down Expand Up @@ -1073,9 +1072,8 @@ const translations = {
approvedAmount: ({amount}: ApprovedAmountParams) => `aprobó ${amount}`,
approvedMessage: `aprobado`,
unapproved: `no aprobado`,
automaticallyForwardedAmount: ({amount}: ForwardedAmountParams) =>
`aprobó ${amount} mediante <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">reglas del espacio de trabajo</a>`,
forwardedAmount: ({amount}: ForwardedAmountParams) => `aprobó ${amount}`,
automaticallyForwarded: `aprobó mediante <a href="${CONST.CONFIGURE_EXPENSE_REPORT_RULES_HELP_URL}">reglas del espacio de trabajo</a>`,
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`,
Expand Down
3 changes: 0 additions & 3 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -795,7 +793,6 @@ export type {
ElectronicFundsParams,
EnterMagicCodeParams,
FormattedMaxLengthParams,
ForwardedAmountParams,
GoBackMessageParams,
GoToRoomParams,
HeldRequestParams,
Expand Down
6 changes: 2 additions & 4 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,13 @@ import {
getDisplayNameForParticipant,
getDowngradeWorkspaceMessage,
getIcons,
getIOUForwardedMessage,
getMoneyRequestSpendBreakdown,
getParticipantsAccountIDsForDisplay,
getPolicyChangeMessage,
getPolicyName,
getReimbursementDeQueuedOrCanceledActionMessage,
getReimbursementQueuedActionMessage,
getRejectedReportMessage,
getReportAutomaticallyForwardedMessage,
getReportLastMessage,
getReportName,
getReportNotificationPreference,
Expand Down Expand Up @@ -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();
Expand Down
84 changes: 4 additions & 80 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -173,7 +167,6 @@ import {
isActionableJoinRequestPending,
isActionableTrackExpense,
isActionOfType,
isApprovedAction,
isApprovedOrSubmittedReportAction,
isCardIssuedAction,
isClosedAction,
Expand All @@ -182,7 +175,6 @@ import {
isDeletedAction,
isDeletedParentAction,
isExportIntegrationAction,
isForwardedAction,
isIntegrationMessageAction,
isMarkAsClosedAction,
isModifiedExpenseAction,
Expand All @@ -199,8 +191,6 @@ import {
isRoomChangeLogAction,
isSentMoneyReportAction,
isSplitBillAction as isSplitBillReportAction,
isSubmittedAction,
isSubmittedAndClosedAction,
isThreadParentMessage,
isTrackExpenseAction,
isTransactionThread,
Expand Down Expand Up @@ -4742,8 +4732,6 @@ function getReportNameInternal({
reportNameValuePairs,
policies,
}: GetReportNameParams): string {
const reportID = report?.reportID;

let formattedName: string | undefined;
let parentReportAction: OnyxEntry<ReportAction>;
if (parentReportActionParam) {
Expand All @@ -4767,9 +4755,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();
Expand Down Expand Up @@ -5768,68 +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;
}

/**
* 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<typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED>, reportOrID: OnyxInputOrEntry<Report> | 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<typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED>,
reportOrID: OnyxInputOrEntry<Report> | 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');
}
Expand Down Expand Up @@ -5922,7 +5848,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}`;
Expand Down Expand Up @@ -10948,8 +10874,6 @@ export {
prepareOnboardingOnyxData,
getIOUReportActionDisplayMessage,
getIOUReportActionMessage,
getReportAutomaticallyForwardedMessage,
getIOUForwardedMessage,
getRejectedReportMessage,
getWorkspaceNameUpdatedMessage,
getDeletedTransactionMessage,
Expand Down
6 changes: 2 additions & 4 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ import {
getChildReportNotificationPreference as getChildReportNotificationPreferenceReportUtils,
getDeletedTransactionMessage,
getDowngradeWorkspaceMessage,
getIOUForwardedMessage,
getIOUReportActionDisplayMessage,
getOriginalReportID,
getPolicyChangeMessage,
getReimbursementDeQueuedOrCanceledActionMessage,
getReimbursementQueuedActionMessage,
getRejectedReportMessage,
getReportAutomaticallyForwardedMessage,
getReportName,
getReportPreviewMessage,
getUpgradeWorkspaceMessage,
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 3 additions & 9 deletions src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ import {
getDisplayNamesWithTooltips,
getDowngradeWorkspaceMessage,
getIconsForParticipants,
getIOUForwardedMessage,
getMovedTransactionMessage,
getPolicyChangeMessage,
getRejectedReportMessage,
Expand Down Expand Up @@ -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<OnyxTypes.Policy>;

Expand Down Expand Up @@ -397,7 +393,6 @@ function PureReportActionItem({
clearAllRelatedReportActionErrors = () => {},
dismissTrackExpenseActionableWhisper = () => {},
userBillingFundID,
reportAutomaticallyForwardedMessage,
policies,
shouldShowBorder,
}: PureReportActionItemProps) {
Expand Down Expand Up @@ -1029,11 +1024,11 @@ function PureReportActionItem({
if (wasAutoForwarded) {
children = (
<ReportActionItemBasicMessage>
<RenderHTML html={`<comment><muted-text>${reportAutomaticallyForwardedMessage}</muted-text></comment>`} />
<RenderHTML html={`<comment><muted-text>${translate('iou.automaticallyForwarded')}</muted-text></comment>`} />
</ReportActionItemBasicMessage>
);
} else {
children = <ReportActionItemBasicMessage message={getIOUForwardedMessage(action, report)} />;
children = <ReportActionItemBasicMessage message={translate('iou.forwarded')} />;
}
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) {
children = <ReportActionItemBasicMessage message={getRejectedReportMessage()} />;
Expand Down Expand Up @@ -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
);
});
2 changes: 0 additions & 2 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
getIndicatedMissingPaymentMethod,
getOriginalReportID,
getReimbursementDeQueuedOrCanceledActionMessage,
getReportAutomaticallyForwardedMessage,
getTransactionsWithReceipts,
isArchivedNonExpenseReportWithID,
isChatThread,
Expand Down Expand Up @@ -102,7 +101,6 @@ function ReportActionItem({action, report, ...props}: PureReportActionItemProps)
clearAllRelatedReportActionErrors={clearAllRelatedReportActionErrors}
dismissTrackExpenseActionableWhisper={dismissTrackExpenseActionableWhisper}
userBillingFundID={userBillingFundID}
reportAutomaticallyForwardedMessage={getReportAutomaticallyForwardedMessage(action as ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED>, reportID)}
/>
);
}
Expand Down