Skip to content

Commit 3b32f83

Browse files
authored
Merge pull request #59706 from FitseTLT/fix-remove-amount-from-submitted-approved-system-messages
Fix - Remove $XX.XX from the submitted and approved system messages
2 parents 9ef07ce + cdcec1e commit 3b32f83

6 files changed

Lines changed: 59 additions & 34 deletions

File tree

src/languages/en.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import type {
6767
DeleteTransactionParams,
6868
DemotedFromWorkspaceParams,
6969
DidSplitAmountMessageParams,
70+
DisplayNameParams,
7071
DuplicateTransactionParams,
7172
EarlyDiscountSubtitleParams,
7273
EarlyDiscountTitleParams,
@@ -184,7 +185,6 @@ import type {
184185
ToValidateLoginParams,
185186
TransferParams,
186187
TrialStartedTitleParams,
187-
UnapprovedParams,
188188
UnapproveWithIntegrationWarningParams,
189189
UnreportedTransactionParams,
190190
UnshareParams,
@@ -1015,8 +1015,8 @@ const translations = {
10151015
sendInvoice: ({amount}: RequestAmountParams) => `Send ${amount} invoice`,
10161016
submitAmount: ({amount}: RequestAmountParams) => `Submit ${amount}`,
10171017
submittedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `submitted ${formattedAmount}${comment ? ` for ${comment}` : ''}`,
1018-
automaticallySubmittedAmount: ({formattedAmount}: RequestedAmountMessageParams) =>
1019-
`automatically submitted ${formattedAmount} via <a href="${CONST.DELAYED_SUBMISSION_HELP_URL}">delayed submission</a>`,
1018+
submittedWithDisplayName: ({displayName}: DisplayNameParams) => `${displayName} submitted`,
1019+
automaticallySubmitted: ({displayName}: DisplayNameParams) => `${displayName} submitted via <a href="${CONST.DELAYED_SUBMISSION_HELP_URL}">delayed submission</a>`,
10201020
trackedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `tracking ${formattedAmount}${comment ? ` for ${comment}` : ''}`,
10211021
splitAmount: ({amount}: SplitAmountParams) => `split ${amount}`,
10221022
didSplitAmount: ({formattedAmount, comment}: DidSplitAmountMessageParams) => `split ${formattedAmount}${comment ? ` for ${comment}` : ''}`,
@@ -1031,10 +1031,10 @@ const translations = {
10311031
managerApprovedAmount: ({manager, amount}: ManagerApprovedAmountParams) => `${manager} approved ${amount}`,
10321032
payerSettled: ({amount}: PayerSettledParams) => `paid ${amount}`,
10331033
payerSettledWithMissingBankAccount: ({amount}: PayerSettledParams) => `paid ${amount}. Add a bank account to receive your payment.`,
1034-
automaticallyApprovedAmount: ({amount}: ApprovedAmountParams) =>
1035-
`automatically approved ${amount} via <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">workspace rules</a>`,
10361034
approvedAmount: ({amount}: ApprovedAmountParams) => `approved ${amount}`,
1037-
unapprovedAmount: ({amount}: UnapprovedParams) => `unapproved ${amount}`,
1035+
automaticallyApproved: ({displayName}: DisplayNameParams) => `${displayName} approved via <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">workspace rules</a>`,
1036+
approvedWithDisplayName: ({displayName}: DisplayNameParams) => `${displayName} approved`,
1037+
unapproved: ({displayName}: DisplayNameParams) => `${displayName} unapproved`,
10381038
automaticallyForwardedAmount: ({amount}: ForwardedAmountParams) =>
10391039
`automatically approved ${amount} via <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">workspace rules</a>`,
10401040
forwardedAmount: ({amount}: ForwardedAmountParams) => `approved ${amount}`,

src/languages/es.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import type {
6666
DeleteTransactionParams,
6767
DemotedFromWorkspaceParams,
6868
DidSplitAmountMessageParams,
69+
DisplayNameParams,
6970
DuplicateTransactionParams,
7071
EarlyDiscountSubtitleParams,
7172
EarlyDiscountTitleParams,
@@ -183,7 +184,6 @@ import type {
183184
ToValidateLoginParams,
184185
TransferParams,
185186
TrialStartedTitleParams,
186-
UnapprovedParams,
187187
UnapproveWithIntegrationWarningParams,
188188
UnreportedTransactionParams,
189189
UnshareParams,
@@ -1010,8 +1010,8 @@ const translations = {
10101010
sendInvoice: ({amount}: RequestAmountParams) => `Enviar factura de ${amount}`,
10111011
submitAmount: ({amount}: RequestAmountParams) => `Solicitar ${amount}`,
10121012
submittedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `solicitó ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
1013-
automaticallySubmittedAmount: ({formattedAmount}: RequestedAmountMessageParams) =>
1014-
`se enviaron automáticamente ${formattedAmount} mediante <a href="${CONST.DELAYED_SUBMISSION_HELP_URL}">envío diferido</a>`,
1013+
submittedWithDisplayName: ({displayName}: DisplayNameParams) => `${displayName} enviado`,
1014+
automaticallySubmitted: ({displayName}: DisplayNameParams) => `${displayName} enviado mediante <a href="${CONST.DELAYED_SUBMISSION_HELP_URL}">envío diferido</a>`,
10151015
trackedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `realizó un seguimiento de ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
10161016
splitAmount: ({amount}: SplitAmountParams) => `dividir ${amount}`,
10171017
didSplitAmount: ({formattedAmount, comment}: DidSplitAmountMessageParams) => `dividió ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
@@ -1026,10 +1026,11 @@ const translations = {
10261026
managerApprovedAmount: ({manager, amount}: ManagerApprovedAmountParams) => `${manager} aprobó ${amount}`,
10271027
payerSettled: ({amount}: PayerSettledParams) => `pagó ${amount}`,
10281028
payerSettledWithMissingBankAccount: ({amount}: PayerSettledParams) => `pagó ${amount}. Agrega una cuenta bancaria para recibir tu pago.`,
1029-
automaticallyApprovedAmount: ({amount}: ApprovedAmountParams) =>
1030-
`aprobado automáticamente ${amount} según las <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">reglas del espacio de trabajo</a>`,
10311029
approvedAmount: ({amount}: ApprovedAmountParams) => `aprobó ${amount}`,
1032-
unapprovedAmount: ({amount}: UnapprovedParams) => `desaprobó ${amount}`,
1030+
automaticallyApproved: ({displayName}: DisplayNameParams) =>
1031+
`${displayName} aprobado mediante <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">reglas del espacio de trabajo</a>`,
1032+
approvedWithDisplayName: ({displayName}: DisplayNameParams) => `${displayName} aprobado`,
1033+
unapproved: ({displayName}: DisplayNameParams) => `${displayName} no aprobado`,
10331034
automaticallyForwardedAmount: ({amount}: ForwardedAmountParams) =>
10341035
`aprobado automáticamente ${amount} según las <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">reglas del espacio de trabajo</a>`,
10351036
forwardedAmount: ({amount}: ForwardedAmountParams) => `aprobó ${amount}`,

src/languages/params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ type CompanyCardFeedNameParams = {feedName: string};
156156

157157
type PayerPaidAmountParams = {payer?: string; amount: number | string};
158158

159+
type DisplayNameParams = {displayName: string};
160+
159161
type ApprovedAmountParams = {amount: number | string};
160162

161163
type ForwardedAmountParams = {amount: number | string};
@@ -370,8 +372,6 @@ type UnshareParams = {to: string};
370372

371373
type StripePaidParams = {amount: string; currency: string};
372374

373-
type UnapprovedParams = {amount: string};
374-
375375
type RemoveMembersWarningPrompt = {
376376
memberName: string;
377377
ownerName: string;
@@ -766,6 +766,7 @@ export type {
766766
AdminCanceledRequestParams,
767767
AlreadySignedInParams,
768768
ApprovedAmountParams,
769+
DisplayNameParams,
769770
BeginningOfChatHistoryAdminRoomPartOneParams,
770771
BeginningOfChatHistoryAnnounceRoomPartOneParams,
771772
BeginningOfChatHistoryAnnounceRoomPartTwo,
@@ -884,7 +885,6 @@ export type {
884885
ShareParams,
885886
UnshareParams,
886887
StripePaidParams,
887-
UnapprovedParams,
888888
RemoveMembersWarningPrompt,
889889
ApprovalWorkflowErrorParams,
890890
ConnectionNameParams,

src/libs/ReportUtils.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5623,30 +5623,32 @@ function getFormattedAmount(reportAction: ReportAction, report?: Report | null)
56235623
return formattedAmount;
56245624
}
56255625

5626+
function getActorDisplayName(action: ReportAction) {
5627+
const actorAccountID = getReportActionActorAccountID(action, undefined, undefined, undefined);
5628+
5629+
return getDisplayNameForParticipant({accountID: actorAccountID});
5630+
}
5631+
56265632
function getReportAutomaticallySubmittedMessage(
56275633
reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED> | ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED>,
5628-
report?: Report,
56295634
) {
5630-
return translateLocal('iou.automaticallySubmittedAmount', {formattedAmount: getFormattedAmount(reportAction, report)});
5635+
return translateLocal('iou.automaticallySubmitted', {displayName: getActorDisplayName(reportAction)});
56315636
}
56325637

5633-
function getIOUSubmittedMessage(
5634-
reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED> | ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED>,
5635-
report?: Report,
5636-
) {
5637-
return translateLocal('iou.submittedAmount', {formattedAmount: getFormattedAmount(reportAction, report)});
5638+
function getIOUSubmittedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED> | ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED>) {
5639+
return translateLocal('iou.submittedWithDisplayName', {displayName: getActorDisplayName(reportAction)});
56385640
}
56395641

5640-
function getReportAutomaticallyApprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.APPROVED>, report?: Report) {
5641-
return translateLocal('iou.automaticallyApprovedAmount', {amount: getFormattedAmount(reportAction, report)});
5642+
function getReportAutomaticallyApprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.APPROVED>) {
5643+
return translateLocal('iou.automaticallyApproved', {displayName: getActorDisplayName(reportAction)});
56425644
}
56435645

5644-
function getIOUUnapprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.UNAPPROVED>, report?: Report) {
5645-
return translateLocal('iou.unapprovedAmount', {amount: getFormattedAmount(reportAction, report)});
5646+
function getIOUUnapprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.UNAPPROVED>) {
5647+
return translateLocal('iou.unapproved', {displayName: getActorDisplayName(reportAction)});
56465648
}
56475649

5648-
function getIOUApprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.APPROVED>, report?: Report) {
5649-
return translateLocal('iou.approvedAmount', {amount: getFormattedAmount(reportAction, report)});
5650+
function getIOUApprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.APPROVED>) {
5651+
return translateLocal('iou.approvedWithDisplayName', {displayName: getActorDisplayName(reportAction)});
56505652
}
56515653

56525654
/**

src/pages/home/report/PureReportActionItem.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -956,25 +956,25 @@ function PureReportActionItem({
956956
if (wasSubmittedViaHarvesting) {
957957
children = (
958958
<ReportActionItemBasicMessage>
959-
<RenderHTML html={`<comment><muted-text>${getReportAutomaticallySubmittedMessage(action, report)}</muted-text></comment>`} />
959+
<RenderHTML html={`<comment><muted-text>${getReportAutomaticallySubmittedMessage(action)}</muted-text></comment>`} />
960960
</ReportActionItemBasicMessage>
961961
);
962962
} else {
963-
children = <ReportActionItemBasicMessage message={getIOUSubmittedMessage(action, report)} />;
963+
children = <ReportActionItemBasicMessage message={getIOUSubmittedMessage(action)} />;
964964
}
965965
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.APPROVED)) {
966966
const wasAutoApproved = getOriginalMessage(action)?.automaticAction ?? false;
967967
if (wasAutoApproved) {
968968
children = (
969969
<ReportActionItemBasicMessage>
970-
<RenderHTML html={`<comment><muted-text>${getReportAutomaticallyApprovedMessage(action, report)}</muted-text></comment>`} />
970+
<RenderHTML html={`<comment><muted-text>${getReportAutomaticallyApprovedMessage(action)}</muted-text></comment>`} />
971971
</ReportActionItemBasicMessage>
972972
);
973973
} else {
974-
children = <ReportActionItemBasicMessage message={getIOUApprovedMessage(action, report)} />;
974+
children = <ReportActionItemBasicMessage message={getIOUApprovedMessage(action)} />;
975975
}
976976
} else if (isUnapprovedAction(action)) {
977-
children = <ReportActionItemBasicMessage message={getIOUUnapprovedMessage(action, report)} />;
977+
children = <ReportActionItemBasicMessage message={getIOUUnapprovedMessage(action)} />;
978978
} else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) {
979979
const wasAutoForwarded = getOriginalMessage(action)?.automaticAction ?? false;
980980
if (wasAutoForwarded) {

tests/unit/ReportUtilsTest.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,35 @@ describe('ReportUtils', () => {
536536
};
537537
const submittedParentReportAction = {
538538
actionName: CONST.REPORT.ACTIONS.TYPE.SUBMITTED,
539+
adminAccountID: 1,
539540
originalMessage: {
540541
amount: 169,
541542
currency: 'USD',
542543
},
543544
} as ReportAction;
544545

545-
expect(getReportName(threadOfSubmittedReportAction, policy, submittedParentReportAction)).toBe('submitted $1.69');
546+
expect(getReportName(threadOfSubmittedReportAction, policy, submittedParentReportAction)).toBe('Ragnar Lothbrok submitted');
547+
});
548+
549+
test('Manually Approved Report Action', () => {
550+
const threadOfApprovedReportAction = {
551+
...LHNTestUtils.getFakeReport(),
552+
type: CONST.REPORT.TYPE.EXPENSE,
553+
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
554+
statusNum: CONST.REPORT.STATUS_NUM.APPROVED,
555+
parentReportID: '101',
556+
policyID: policy.id,
557+
};
558+
const approvedParentReportAction = {
559+
actionName: CONST.REPORT.ACTIONS.TYPE.APPROVED,
560+
actorAccountID: 1,
561+
originalMessage: {
562+
amount: 169,
563+
currency: 'USD',
564+
},
565+
} as ReportAction;
566+
567+
expect(getReportName(threadOfApprovedReportAction, policy, approvedParentReportAction)).toBe('Ragnar Lothbrok approved');
546568
});
547569

548570
test('Invited/Removed Room Member Action', () => {

0 commit comments

Comments
 (0)