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 @@ -4282,7 +4282,7 @@ 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}`,
unapproved: ({amount}: UnapprovedParams) => `unapproved ${amount}`,
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -4327,7 +4327,7 @@ 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}`,
unapproved: ({amount}: UnapprovedParams) => `no aprobado ${amount}`,
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
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
4 changes: 2 additions & 2 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,8 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
} else {
lastMessageTextFromReport = ReportUtils.getIOUSubmittedMessage(lastReportAction);
}
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(lastReportAction);
} else if (ReportActionUtils.isUnapprovedOrApprovedAction(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getIOUUnapprovedOrApprovedMessage(lastReportAction);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.FORWARDED) {
lastMessageTextFromReport = ReportUtils.getIOUForwardedMessage(lastReportAction, report);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) {
Expand Down
7 changes: 7 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ function isApprovedAction(reportAction: OnyxInputOrEntry<ReportAction>): reportA
return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.APPROVED);
}

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

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 @@ -1848,6 +1854,7 @@ export {
isSubmittedAction,
isSubmittedAndClosedAction,
isApprovedAction,
isUnapprovedOrApprovedAction,
isForwardedAction,
isWhisperActionTargetedToOthers,
isTagModificationAction,
Expand Down
18 changes: 12 additions & 6 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3789,8 +3789,8 @@ function getReportName(
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) {
return getRejectedReportMessage();
}
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
return getIOUApprovedMessage(parentReportAction);
if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED || parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNAPPROVED) {
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
return getIOUUnapprovedOrApprovedMessage(parentReportAction);
}

if (isChatThread(report)) {
Expand Down Expand Up @@ -4520,7 +4520,7 @@ function getFormattedAmount(reportAction: ReportAction) {
if (
!ReportActionsUtils.isSubmittedAction(reportAction) &&
!ReportActionsUtils.isForwardedAction(reportAction) &&
!ReportActionsUtils.isApprovedAction(reportAction) &&
!ReportActionsUtils.isUnapprovedOrApprovedAction(reportAction) &&
!ReportActionsUtils.isSubmittedAndClosedAction(reportAction)
) {
return '';
Expand All @@ -4540,8 +4540,14 @@ function getIOUSubmittedMessage(reportAction: ReportAction<typeof CONST.REPORT.A
return Localize.translateLocal('iou.submittedAmount', {formattedAmount: getFormattedAmount(reportAction)});
}

function getIOUApprovedMessage(reportAction: ReportAction) {
return Localize.translateLocal('iou.approvedAmount', {amount: getFormattedAmount(reportAction)});
function getIOUUnapprovedOrApprovedMessage(reportAction: ReportAction) {
let translationKey: TranslationPaths;
if (ReportActionsUtils.isApprovedAction(reportAction)) {
translationKey = 'iou.approvedAmount';
} else {
translationKey = 'report.actions.type.unapproved';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, Should we add a new translation key 'iou.unapprovedAmount' with the correct translation (need to confirm again). I am not sure if we also want to use 'report.actions.type.unapproved' translation key here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I see in the report detail we use another translation for unapproved action

unapprove: 'Desaprobar',

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iwiznia Could you please help to confirm which translation we should use here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me a bit more context on what exactly is this showing?

Copy link
Contributor

@DylanDylann DylanDylann Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iwiznia When the admin unapproves a request, a system message will display "unapproved X", I am asking the Spanish translation for this system message.

Hmm, Should we add a new translation key 'iou.unapprovedAmount' with the correct translation (need to confirm again). I am not sure if we also want to use 'report.actions.type.unapproved' translation key here because I see in the report detail we use another translation for unapproved action "unapprove: 'Desaprobar'"

Screenshot 2024-10-08 at 11 00 57

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok thanks! the translation would be desaprobó

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkdengineer Please help to update this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DylanDylann updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkdengineer I think we should create a new translation key iou.approvedAmount

}
return Localize.translateLocal(translationKey, {amount: getFormattedAmount(reportAction)});
}

/**
Expand Down Expand Up @@ -8125,7 +8131,7 @@ export {
getGroupChatName,
getIOUReportActionDisplayMessage,
getIOUReportActionMessage,
getIOUApprovedMessage,
getIOUUnapprovedOrApprovedMessage,
getIOUForwardedMessage,
getRejectedReportMessage,
getWorkspaceNameUpdatedMessage,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ const ContextMenuActions: ContextMenuAction[] = [
) {
const displayMessage = ReportUtils.getIOUSubmittedMessage(reportAction);
Clipboard.setString(displayMessage);
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
const displayMessage = ReportUtils.getIOUApprovedMessage(reportAction);
} else if (ReportActionsUtils.isUnapprovedOrApprovedAction(reportAction)) {
const displayMessage = ReportUtils.getIOUUnapprovedOrApprovedMessage(reportAction);
Clipboard.setString(displayMessage);
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.FORWARDED) {
const displayMessage = ReportUtils.getIOUForwardedMessage(reportAction, reportID);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,8 @@ function ReportActionItem({
} else {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUSubmittedMessage(action)} />;
}
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUApprovedMessage(action)} />;
} else if (ReportActionsUtils.isUnapprovedOrApprovedAction(action)) {
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUUnapprovedOrApprovedMessage(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.FORWARDED) {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUForwardedMessage(action, report)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REJECTED) {
Expand Down
Loading