Skip to content

Commit

Permalink
Merge pull request Expensify#49831 from nkdengineer/fix/49160
Browse files Browse the repository at this point in the history
fix: Square bracket displayed in system message for unapproved expense report
  • Loading branch information
iwiznia authored Oct 11, 2024
2 parents 12e41b1 + 8bef74e commit 1220039
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ const translations = {
automaticallyApprovedAmount: ({amount}: ApprovedAmountParams) =>
`automatically approved ${amount} via <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">workspace rules</a>`,
approvedAmount: ({amount}: ApprovedAmountParams) => `approved ${amount}`,
unapprovedAmount: ({amount}: UnapprovedParams) => `unapproved ${amount}`,
automaticallyForwardedAmount: ({amount}: ForwardedAmountParams) =>
`automatically approved ${amount} via <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">workspace rules</a>`,
forwardedAmount: ({amount}: ForwardedAmountParams) => `approved ${amount}`,
Expand Down Expand Up @@ -4395,7 +4396,6 @@ const translations = {
unshare: ({to}: UnshareParams) => `removed user ${to}`,
stripePaid: ({amount, currency}: StripePaidParams) => `paid ${currency}${amount}`,
takeControl: `took control`,
unapproved: ({amount, currency}: UnapprovedParams) => `unapproved ${currency}${amount}`,
integrationSyncFailed: ({label, errorMessage}: IntegrationSyncFailedParams) => `failed to sync with ${label} ("${errorMessage}")`,
addEmployee: ({email, role}: AddEmployeeParams) => `added ${email} as ${role === 'user' ? 'member' : 'admin'}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `updated the role of ${email} from ${currentRole} to ${newRole}`,
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ const translations = {
automaticallyApprovedAmount: ({amount}: ApprovedAmountParams) =>
`aprobado automáticamente ${amount} según las <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">reglas del espacio de trabajo</a>`,
approvedAmount: ({amount}: ApprovedAmountParams) => `aprobó ${amount}`,
unapprovedAmount: ({amount}: UnapprovedParams) => `desaprobó ${amount}`,
automaticallyForwardedAmount: ({amount}: ForwardedAmountParams) =>
`aprobado automáticamente ${amount} según las <a href="${CONST.CONFIGURE_REIMBURSEMENT_SETTINGS_HELP_URL}">reglas del espacio de trabajo</a>`,
forwardedAmount: ({amount}: ForwardedAmountParams) => `aprobó ${amount}`,
Expand Down Expand Up @@ -4443,7 +4444,6 @@ const translations = {
unshare: ({to}: UnshareParams) => `usuario eliminado ${to}`,
stripePaid: ({amount, currency}: StripePaidParams) => `pagado ${currency}${amount}`,
takeControl: `tomó el control`,
unapproved: ({amount, currency}: UnapprovedParams) => `no aprobado ${currency}${amount}`,
integrationSyncFailed: ({label, errorMessage}: IntegrationSyncFailedParams) => `no se pudo sincronizar con ${label} ("${errorMessage}")`,
addEmployee: ({email, role}: AddEmployeeParams) => `agregó a ${email} como ${role === 'user' ? 'miembro' : 'administrador'}`,
updateRole: ({email, currentRole, newRole}: UpdateRoleParams) =>
Expand Down
2 changes: 1 addition & 1 deletion src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ type UnshareParams = {to: string};

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

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

type RemoveMembersWarningPrompt = {
memberName: string;
Expand Down
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,8 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
} else {
lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(lastReportAction);
}
} else if (ReportActionUtils.isUnapprovedAction(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getIOUUnapprovedMessage(lastReportAction);
} else if (ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) {
const {automaticAction} = ReportActionUtils.getOriginalMessage(lastReportAction) ?? {};
if (automaticAction) {
Expand Down
5 changes: 5 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ function isApprovedAction(reportAction: OnyxInputOrEntry<ReportAction>): reportA
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.APPROVED);
}

function isUnapprovedAction(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.UNAPPROVED> {
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.UNAPPROVED);
}

function isForwardedAction(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.FORWARDED> {
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED);
}
Expand Down Expand Up @@ -1865,6 +1869,7 @@ export {
isSubmittedAction,
isSubmittedAndClosedAction,
isApprovedAction,
isUnapprovedAction,
isForwardedAction,
isWhisperActionTargetedToOthers,
isTagModificationAction,
Expand Down
9 changes: 9 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3849,6 +3849,9 @@ function getReportName(
}
return getIOUApprovedMessage(parentReportAction);
}
if (ReportActionsUtils.isUnapprovedAction(parentReportAction)) {
return getIOUUnapprovedMessage(parentReportAction);
}

if (isChatThread(report)) {
if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) {
Expand Down Expand Up @@ -4599,6 +4602,7 @@ function getFormattedAmount(reportAction: ReportAction) {
!ReportActionsUtils.isSubmittedAction(reportAction) &&
!ReportActionsUtils.isForwardedAction(reportAction) &&
!ReportActionsUtils.isApprovedAction(reportAction) &&
!ReportActionsUtils.isUnapprovedAction(reportAction) &&
!ReportActionsUtils.isSubmittedAndClosedAction(reportAction)
) {
return '';
Expand All @@ -4622,6 +4626,10 @@ function getReportAutomaticallyApprovedMessage(reportAction: ReportAction<typeof
return Localize.translateLocal('iou.automaticallyApprovedAmount', {amount: getFormattedAmount(reportAction)});
}

function getIOUUnapprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.UNAPPROVED>) {
return Localize.translateLocal('iou.unapprovedAmount', {amount: getFormattedAmount(reportAction)});
}

function getIOUApprovedMessage(reportAction: ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.APPROVED>) {
return Localize.translateLocal('iou.approvedAmount', {amount: getFormattedAmount(reportAction)});
}
Expand Down Expand Up @@ -8241,6 +8249,7 @@ export {
getIOUReportActionDisplayMessage,
getIOUReportActionMessage,
getReportAutomaticallyApprovedMessage,
getIOUUnapprovedMessage,
getIOUApprovedMessage,
getReportAutomaticallyForwardedMessage,
getIOUForwardedMessage,
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ const ContextMenuActions: ContextMenuAction[] = [
} else {
Clipboard.setString(ReportUtils.getIOUApprovedMessage(reportAction));
}
} else if (ReportActionsUtils.isUnapprovedAction(reportAction)) {
Clipboard.setString(ReportUtils.getIOUUnapprovedMessage(reportAction));
} else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) {
const {automaticAction} = ReportActionsUtils.getOriginalMessage(reportAction) ?? {};
if (automaticAction) {
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 @@ -664,6 +664,8 @@ function ReportActionItem({
} else {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUApprovedMessage(action)} />;
}
} else if (ReportActionsUtils.isUnapprovedAction(action)) {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUUnapprovedMessage(action)} />;
} else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) {
const wasAutoForwarded = ReportActionsUtils.getOriginalMessage(action)?.automaticAction ?? false;
if (wasAutoForwarded) {
Expand Down

0 comments on commit 1220039

Please sign in to comment.