Skip to content

Commit

Permalink
Merge pull request #45020 from Expensify/marco-addTranslationApproved…
Browse files Browse the repository at this point in the history
…Action

Add Spanish translation to system message for approval
  • Loading branch information
MonilBhavsar authored Jul 10, 2024
2 parents 4c235a7 + 33720c9 commit 987c965
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,11 @@ function isSearchStringMatchUserDetails(personalDetail: PersonalDetails, searchV
* Get the last message text from the report directly or from other sources for special cases.
*/
function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails: Partial<PersonalDetails> | null, policy?: OnyxEntry<Policy>): string {
const lastReportAction = visibleReportActionItems[report?.reportID ?? '-1'] ?? null;
const reportID = report?.reportID ?? '-1';
const lastReportAction = visibleReportActionItems[reportID] ?? null;

// some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action
const lastOriginalReportAction = lastReportActions[report?.reportID ?? '-1'] ?? null;
const lastOriginalReportAction = lastReportActions[reportID] ?? null;
let lastMessageTextFromReport = '';

if (ReportUtils.isArchivedRoom(report)) {
Expand Down Expand Up @@ -720,8 +721,10 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(TaskUtils.getTaskReportActionMessage(lastReportAction).text);
} else if (ReportActionUtils.isCreatedTaskReportAction(lastReportAction)) {
lastMessageTextFromReport = TaskUtils.getTaskCreatedMessage(lastReportAction);
} else if (ReportActionUtils.isApprovedOrSubmittedReportAction(lastReportAction)) {
lastMessageTextFromReport = ReportActionUtils.getReportActionMessageText(lastReportAction);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) {
lastMessageTextFromReport = ReportUtils.getIOUSubmittedMessage(reportID);
} else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) {
lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(reportID);
}

return lastMessageTextFromReport || (report?.lastMessageText ?? '');
Expand Down
13 changes: 11 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4002,11 +4002,19 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa
return expenseReport;
}

function getIOUSubmittedMessage(reportID: string) {
function getFormattedAmount(reportID: string) {
const report = getReportOrDraftReport(reportID);
const linkedReport = isChatThread(report) ? getParentReport(report) : report;
const formattedAmount = CurrencyUtils.convertToDisplayString(Math.abs(linkedReport?.total ?? 0), linkedReport?.currency);
return Localize.translateLocal('iou.submittedAmount', {formattedAmount});
return formattedAmount;
}

function getIOUSubmittedMessage(reportID: string) {
return Localize.translateLocal('iou.submittedAmount', {formattedAmount: getFormattedAmount(reportID)});
}

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

/**
Expand Down Expand Up @@ -7167,6 +7175,7 @@ export {
getGroupChatName,
getIOUReportActionDisplayMessage,
getIOUReportActionMessage,
getIOUApprovedMessage,
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 @@ -400,6 +400,9 @@ const ContextMenuActions: ContextMenuAction[] = [
} else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) {
const displayMessage = ReportUtils.getIOUSubmittedMessage(reportID);
Clipboard.setString(displayMessage);
} 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.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 @@ -621,6 +621,8 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getMessageOfOldDotReportAction(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) {
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.HOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.heldExpense')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) {
Expand Down

0 comments on commit 987c965

Please sign in to comment.