Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show FORWARDED report action #46229

Merged
merged 12 commits into from
Jul 30, 2024
4 changes: 2 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
EnterMagicCodeParams,
ExportedToIntegrationParams,
FormattedMaxLengthParams,
ForwardedParams,
ForwardedAmountParams,
GoBackMessageParams,
GoToRoomParams,
InstantSummaryParams,
Expand Down Expand Up @@ -744,6 +744,7 @@ export default {
managerApprovedAmount: ({manager, amount}: ManagerApprovedAmountParams) => `${manager} approved ${amount}`,
payerSettled: ({amount}: PayerSettledParams) => `paid ${amount}`,
approvedAmount: ({amount}: ApprovedAmountParams) => `approved ${amount}`,
forwardedAmount: ({amount}: ForwardedAmountParams) => `approved ${amount}`,
waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `started settling up. Payment is on hold until ${submitterDisplayName} adds a bank account.`,
adminCanceledRequest: ({manager, amount}: AdminCanceledRequestParams) => `${manager ? `${manager}: ` : ''}cancelled the ${amount} payment.`,
canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) =>
Expand Down Expand Up @@ -3708,7 +3709,6 @@ export default {
nonReimbursableLink: 'View company card expenses.',
pending: ({label}: ExportedToIntegrationParams) => `started exporting this report to ${label}...`,
},
forwarded: ({amount, currency}: ForwardedParams) => `approved ${currency}${amount}`,
integrationsMessage: (errorMessage: string, label: string) => `failed to export this report to ${label} ("${errorMessage}").`,
managerAttachReceipt: `added a receipt`,
managerDetachReceipt: `removed a receipt`,
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import type {
EnterMagicCodeParams,
ExportedToIntegrationParams,
FormattedMaxLengthParams,
ForwardedParams,
ForwardedAmountParams,
GoBackMessageParams,
GoToRoomParams,
InstantSummaryParams,
Expand Down Expand Up @@ -740,6 +740,7 @@ export default {
managerApprovedAmount: ({manager, amount}: ManagerApprovedAmountParams) => `${manager} aprobó ${amount}`,
payerSettled: ({amount}: PayerSettledParams) => `pagó ${amount}`,
approvedAmount: ({amount}: ApprovedAmountParams) => `aprobó ${amount}`,
forwardedAmount: ({amount}: ForwardedAmountParams) => `aprobó ${amount}`,
waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `inició el pago, pero no se procesará hasta que ${submitterDisplayName} añada una cuenta bancaria`,
adminCanceledRequest: ({manager, amount}: AdminCanceledRequestParams) => `${manager ? `${manager}: ` : ''}canceló el pago de ${amount}.`,
canceledRequest: ({amount, submitterDisplayName}: CanceledRequestParams) =>
Expand Down Expand Up @@ -3766,7 +3767,6 @@ export default {
nonReimbursableLink: 'Ver los gastos de la tarjeta de empresa.',
pending: ({label}: ExportedToIntegrationParams) => `comenzó a exportar este informe a ${label}...`,
},
forwarded: ({amount, currency}: ForwardedParams) => `aprobado ${currency}${amount}`,
integrationsMessage: (errorMessage: string, label: string) => `no se pudo exportar este informe a ${label} ("${errorMessage}").`,
managerAttachReceipt: `agregó un recibo`,
managerDetachReceipt: `quitó un recibo`,
Expand Down
6 changes: 3 additions & 3 deletions src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ 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 @@ -313,8 +315,6 @@ type DelegateSubmitParams = {delegateUser: string; originalManager: string};

type ExportedToIntegrationParams = {label: string; markedManually?: boolean; inProgress?: boolean; lastModified?: string};

type ForwardedParams = {amount: string; currency: string};

type IntegrationsMessageParams = {
label: string;
result: {
Expand Down Expand Up @@ -372,6 +372,7 @@ export type {
EnglishTranslation,
EnterMagicCodeParams,
FormattedMaxLengthParams,
ForwardedAmountParams,
GoBackMessageParams,
GoToRoomParams,
HeldRequestParams,
Expand Down Expand Up @@ -459,7 +460,6 @@ export type {
ChangeTypeParams,
ExportedToIntegrationParams,
DelegateSubmitParams,
ForwardedParams,
IntegrationsMessageParams,
MarkedReimbursedParams,
MarkReimbursedFromIntegrationParams,
Expand Down
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,8 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
lastMessageTextFromReport = ReportUtils.getIOUSubmittedMessage(reportID);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(reportID);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.FORWARDED) {
lastMessageTextFromReport = ReportUtils.getIOUForwardedMessage(reportID);
} else if (ReportActionUtils.isActionableAddPaymentCard(lastReportAction)) {
lastMessageTextFromReport = ReportActionUtils.getReportActionMessageText(lastReportAction);
} else if (lastReportAction?.actionName === 'EXPORTINTEGRATION') {
Expand Down
1 change: 0 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,6 @@ function isOldDotReportAction(action: ReportAction | OldDotReportAction) {
CONST.REPORT.ACTIONS.TYPE.CHANGE_TYPE,
CONST.REPORT.ACTIONS.TYPE.DELEGATE_SUBMIT,
CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_CSV,
CONST.REPORT.ACTIONS.TYPE.FORWARDED,
CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE,
CONST.REPORT.ACTIONS.TYPE.MANAGER_ATTACH_RECEIPT,
CONST.REPORT.ACTIONS.TYPE.MANAGER_DETACH_RECEIPT,
Expand Down
8 changes: 8 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4107,6 +4107,10 @@ function getIOUApprovedMessage(reportID: string) {
return Localize.translateLocal('iou.approvedAmount', {amount: getFormattedAmount(reportID)});
}

function getIOUForwardedMessage(reportID: string) {
return Localize.translateLocal('iou.forwardedAmount', {amount: getFormattedAmount(reportID)});
}

/**
* @param iouReportID - the report ID of the IOU report the action belongs to
* @param type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split)
Expand Down Expand Up @@ -4139,6 +4143,9 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num
case CONST.REPORT.ACTIONS.TYPE.APPROVED:
iouMessage = `approved ${amount}`;
break;
case CONST.REPORT.ACTIONS.TYPE.FORWARDED:
iouMessage = getIOUForwardedMessage(iouReportID);
break;
case CONST.REPORT.ACTIONS.TYPE.UNAPPROVED:
iouMessage = `unapproved ${amount}`;
break;
Expand Down Expand Up @@ -7418,6 +7425,7 @@ export {
getIOUReportActionDisplayMessage,
getIOUReportActionMessage,
getIOUApprovedMessage,
getIOUForwardedMessage,
getIOUSubmittedMessage,
getIcons,
getIconsForParticipants,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ const ContextMenuActions: ContextMenuAction[] = [
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
const displayMessage = ReportUtils.getIOUApprovedMessage(reportID);
Clipboard.setString(displayMessage);
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.FORWARDED) {
const displayMessage = ReportUtils.getIOUForwardedMessage(reportID);
Clipboard.setString(displayMessage);
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
Clipboard.setString(Localize.translateLocal('iou.heldExpense'));
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUSubmittedMessage(report.reportID)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUApprovedMessage(report.reportID)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.FORWARDED) {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUForwardedMessage(report.reportID)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.heldExpense')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) {
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItemFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const MUTED_ACTIONS = [
...Object.values(CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG),
CONST.REPORT.ACTIONS.TYPE.IOU,
CONST.REPORT.ACTIONS.TYPE.APPROVED,
CONST.REPORT.ACTIONS.TYPE.FORWARDED,
CONST.REPORT.ACTIONS.TYPE.UNAPPROVED,
CONST.REPORT.ACTIONS.TYPE.MOVED,
CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_JOIN_REQUEST,
Expand Down
10 changes: 7 additions & 3 deletions src/pages/home/report/ReportActionsListItemRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,13 @@ function ReportActionsListItemRenderer({
shouldDisplayNewMarker={shouldDisplayNewMarker}
shouldShowSubscriptAvatar={
ReportUtils.isPolicyExpenseChat(report) &&
[CONST.REPORT.ACTIONS.TYPE.IOU, CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW, CONST.REPORT.ACTIONS.TYPE.SUBMITTED, CONST.REPORT.ACTIONS.TYPE.APPROVED].some(
(type) => type === reportAction.actionName,
)
[
CONST.REPORT.ACTIONS.TYPE.IOU,
CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW,
CONST.REPORT.ACTIONS.TYPE.SUBMITTED,
CONST.REPORT.ACTIONS.TYPE.APPROVED,
CONST.REPORT.ACTIONS.TYPE.FORWARDED,
].some((type) => type === reportAction.actionName)
}
isMostRecentIOUReportAction={reportAction.reportActionID === mostRecentIOUReportActionID}
index={index}
Expand Down
13 changes: 0 additions & 13 deletions src/types/onyx/OldDotAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type OldDotOriginalMessageActionName =
| 'DELEGATESUBMIT'
| 'EXPORTCSV'
| 'EXPORTINTEGRATION'
| 'FORWARDED'
| 'INTEGRATIONSMESSAGE'
| 'MANAGERATTACHRECEIPT'
| 'MANAGERDETACHRECEIPT'
Expand Down Expand Up @@ -121,18 +120,6 @@ type OriginalMessageExportedToIntegration = {
originalMessage: ExportedToIntegrationParams & Record<string, unknown>;
};

// Currently lacking Params
// type OriginalMessagePolicyTask = {
// /**
// *
// */
// actionName: typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED;
// /**
// *
// */
// originalMessage: ForwardedParams & Record<string, unknown>;
// };

/**
*
*/
Expand Down
14 changes: 13 additions & 1 deletion src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,18 @@ type OriginalMessageApproved = {
expenseReportID: string;
};

/** Model of `forwarded` report action */
type OriginalMessageForwarded = {
/** Forwarded expense amount */
amount: number;

/** Currency of the forwarded expense amount */
currency: string;

/** Report ID of the expense */
expenseReportID: string;
};

/**
*
*/
Expand Down Expand Up @@ -494,7 +506,7 @@ type OriginalMessageMap = {
/** */
[CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION]: OriginalMessageExportIntegration;
/** */
[CONST.REPORT.ACTIONS.TYPE.FORWARDED]: never;
[CONST.REPORT.ACTIONS.TYPE.FORWARDED]: OriginalMessageForwarded;
/** */
[CONST.REPORT.ACTIONS.TYPE.HOLD]: never;
/** */
Expand Down
Loading