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

fix: Square bracket displayed in system message for unapproved expense report #49831

Merged
merged 14 commits into from
Oct 11, 2024
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 @@ -4318,7 +4319,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 @@ -4364,7 +4365,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};
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -3835,6 +3835,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 @@ -4559,6 +4562,7 @@ function getFormattedAmount(reportAction: ReportAction) {
!ReportActionsUtils.isSubmittedAction(reportAction) &&
!ReportActionsUtils.isForwardedAction(reportAction) &&
!ReportActionsUtils.isApprovedAction(reportAction) &&
!ReportActionsUtils.isUnapprovedAction(reportAction) &&
!ReportActionsUtils.isSubmittedAndClosedAction(reportAction)
) {
return '';
Expand All @@ -4582,6 +4586,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 @@ -8201,6 +8209,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 @@ -657,6 +657,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
Loading