diff --git a/src/components/ReportActionItem/ExportIntegration.tsx b/src/components/ReportActionItem/ExportIntegration.tsx index e27038e1f142..ba06311862f7 100644 --- a/src/components/ReportActionItem/ExportIntegration.tsx +++ b/src/components/ReportActionItem/ExportIntegration.tsx @@ -4,8 +4,9 @@ import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; +import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import * as ReportActionUtils from '@libs/ReportActionsUtils'; +import {getExportIntegrationActionFragments} from '@libs/ReportActionsUtils'; import type {ReportAction} from '@src/types/onyx'; type ExportIntegrationProps = { @@ -14,7 +15,8 @@ type ExportIntegrationProps = { function ExportIntegration({action}: ExportIntegrationProps) { const styles = useThemeStyles(); - const fragments = ReportActionUtils.getExportIntegrationActionFragments(action); + const {translate} = useLocalize(); + const fragments = getExportIntegrationActionFragments(translate, action); return ( diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index f675cf270cdc..44a93da19b5b 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -41,18 +41,14 @@ import { getIOUReportIDFromReportActionPreview, getJoinRequestMessage, getLastVisibleMessage, - getLeaveRoomMessage, getMentionedAccountIDsFromAction, getMessageOfOldDotReportAction, getOneTransactionThreadReportID, getOriginalMessage, - getReceiptScanFailedMessage, getRenamedAction, - getReopenedMessage, getReportActionActorAccountID, getReportActionHtml, getReportActionMessageText, - getRetractedMessage, getRoomAvatarUpdatedMessage, getRoomChangeLogMessage, getSortedReportActions, @@ -743,44 +739,58 @@ function getLastMessageTextForReport({ } else if (isActionableAddPaymentCard(lastReportAction)) { lastMessageTextFromReport = getReportActionMessageText(lastReportAction); } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) { - lastMessageTextFromReport = getExportIntegrationLastMessageText(lastReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = getExportIntegrationLastMessageText(translateLocal, lastReportAction); } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED) { - lastMessageTextFromReport = getReceiptScanFailedMessage(); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = translateLocal('iou.receiptScanningFailed'); } else if (lastReportAction?.actionName && isOldDotReportAction(lastReportAction)) { - lastMessageTextFromReport = getMessageOfOldDotReportAction(lastReportAction, false); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = getMessageOfOldDotReportAction(translateLocal, lastReportAction, false); } else if (isActionableJoinRequest(lastReportAction)) { - lastMessageTextFromReport = getJoinRequestMessage(lastReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = getJoinRequestMessage(translateLocal, lastReportAction); } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.LEAVE_ROOM) { - lastMessageTextFromReport = getLeaveRoomMessage(); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = translateLocal('report.actions.type.leftTheChat'); } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RESOLVED_DUPLICATES) { // eslint-disable-next-line @typescript-eslint/no-deprecated lastMessageTextFromReport = translateLocal('violations.resolvedDuplicates'); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) { - lastMessageTextFromReport = Parser.htmlToText(getUpdateRoomDescriptionMessage(lastReportAction)); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = Parser.htmlToText(getUpdateRoomDescriptionMessage(translateLocal, lastReportAction)); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_AVATAR)) { - lastMessageTextFromReport = getRoomAvatarUpdatedMessage(lastReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = getRoomAvatarUpdatedMessage(translateLocal, lastReportAction); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.RETRACTED)) { - lastMessageTextFromReport = getRetractedMessage(); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = translateLocal('iou.retracted'); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.REOPENED)) { - lastMessageTextFromReport = getReopenedMessage(); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = translateLocal('iou.reopened'); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY)) { lastMessageTextFromReport = getPolicyChangeMessage(lastReportAction); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) { - lastMessageTextFromReport = getTravelUpdateMessage(lastReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = getTravelUpdateMessage(translateLocal, lastReportAction); } else if (isInviteOrRemovedAction(lastReportAction)) { - lastMessageTextFromReport = getRoomChangeLogMessage(lastReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = getRoomChangeLogMessage(translateLocal, lastReportAction); } else if (isRenamedAction(lastReportAction)) { - lastMessageTextFromReport = getRenamedAction(lastReportAction, isExpenseReport(report)); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = getRenamedAction(translateLocal, lastReportAction, isExpenseReport(report)); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION)) { lastMessageTextFromReport = getDeletedTransactionMessage(lastReportAction); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) { - lastMessageTextFromReport = Parser.htmlToText(getChangedApproverActionMessage(lastReportAction)); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = Parser.htmlToText(getChangedApproverActionMessage(translateLocal, lastReportAction)); } else if (isMovedAction(lastReportAction)) { lastMessageTextFromReport = Parser.htmlToText(getMovedActionMessage(lastReportAction, report)); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION)) { lastMessageTextFromReport = Parser.htmlToText(getUnreportedTransactionMessage(lastReportAction)); } else if (isActionableMentionWhisper(lastReportAction)) { - lastMessageTextFromReport = Parser.htmlToText(getActionableMentionWhisperMessage(lastReportAction)); + // eslint-disable-next-line @typescript-eslint/no-deprecated + lastMessageTextFromReport = Parser.htmlToText(getActionableMentionWhisperMessage(translateLocal, lastReportAction)); } else if (isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED)) { // eslint-disable-next-line @typescript-eslint/no-deprecated lastMessageTextFromReport = getDynamicExternalWorkflowRoutedMessage(lastReportAction, translateLocal); diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index b73a04f47e13..007075b1ef4a 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -30,8 +30,7 @@ import getBase62ReportID from './getBase62ReportID'; import {isReportMessageAttachment} from './isReportMessageAttachment'; import {toLocaleOrdinal} from './LocaleDigitUtils'; import {formatPhoneNumber} from './LocalePhoneNumber'; -// eslint-disable-next-line @typescript-eslint/no-deprecated -import {formatMessageElementList, translateLocal} from './Localize'; +import {formatMessageElementList} from './Localize'; import Log from './Log'; import type {MessageElementBase, MessageTextElement} from './MessageElement'; import getReportURLForCurrentContext from './Navigation/helpers/getReportURLForCurrentContext'; @@ -1582,8 +1581,12 @@ function isReportActionAttachment(reportAction: OnyxInputOrEntry): } // We pass getReportName as a param to avoid cyclic dependency. -// eslint-disable-next-line @typescript-eslint/no-deprecated -function getMemberChangeMessageElements(reportAction: OnyxEntry, getReportNameCallback: typeof getReportName): readonly MemberChangeMessageElement[] { +function getMemberChangeMessageElements( + translate: LocalizedTranslate, + reportAction: OnyxEntry, + // eslint-disable-next-line @typescript-eslint/no-deprecated + getReportNameCallback: typeof getReportName, +): readonly MemberChangeMessageElement[] { const isInviteAction = isInviteMemberAction(reportAction); const isLeaveAction = isLeavePolicyAction(reportAction); @@ -1592,15 +1595,13 @@ function getMemberChangeMessageElements(reportAction: OnyxEntry, g } // Currently, we only render messages when members are invited - // eslint-disable-next-line @typescript-eslint/no-deprecated - let verb = translateLocal('workspace.invite.removed'); + let verb = translate('workspace.invite.removed'); if (isInviteAction) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - verb = translateLocal('workspace.invite.invited'); + verb = translate('workspace.invite.invited'); } if (isLeaveAction) { - verb = getPolicyChangeLogEmployeeLeftMessage(reportAction); + verb = getPolicyChangeLogEmployeeLeftMessage(translate, reportAction); } const originalMessage = getOriginalMessage(reportAction); @@ -1609,8 +1610,7 @@ function getMemberChangeMessageElements(reportAction: OnyxEntry, g const mentionElements = targetAccountIDs.map((accountID): MemberChangeMessageUserMentionElement => { const personalDetail = personalDetails.find((personal) => personal.accountID === accountID); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const handleText = getEffectiveDisplayName(formatPhoneNumber, personalDetail) ?? translateLocal('common.hidden'); + const handleText = getEffectiveDisplayName(formatPhoneNumber, personalDetail) ?? translate('common.hidden'); return { kind: 'userMention', @@ -1623,8 +1623,7 @@ function getMemberChangeMessageElements(reportAction: OnyxEntry, g // eslint-disable-next-line @typescript-eslint/no-deprecated const roomName = getReportNameCallback(allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${originalMessage?.reportID}`]) || originalMessage?.roomName; if (roomName && originalMessage) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const preposition = isInviteAction ? ` ${translateLocal('workspace.invite.to')} ` : ` ${translateLocal('workspace.invite.from')} `; + const preposition = isInviteAction ? ` ${translate('workspace.invite.to')} ` : ` ${translate('workspace.invite.from')} `; if (originalMessage.reportID) { return [ @@ -1726,7 +1725,7 @@ function getMessageOfOldDotLegacyAction(legacyAction: PartialReportAction) { /** * Helper method to format message of OldDot Actions. */ -function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldDotReportAction, withMarkdown = true): string { +function getMessageOfOldDotReportAction(translate: LocalizedTranslate, oldDotAction: PartialReportAction | OldDotReportAction, withMarkdown = true): string { if (isOldDotLegacyAction(oldDotAction)) { return getMessageOfOldDotLegacyAction(oldDotAction); } @@ -1736,82 +1735,66 @@ function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldD case CONST.REPORT.ACTIONS.TYPE.CHANGE_FIELD: { const {oldValue, newValue, fieldName} = originalMessage; if (!oldValue) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.changeFieldEmpty', {newValue, fieldName}); + return translate('report.actions.type.changeFieldEmpty', {newValue, fieldName}); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.changeField', {oldValue, newValue, fieldName}); + return translate('report.actions.type.changeField', {oldValue, newValue, fieldName}); } case CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_CSV: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.exportedToCSV'); + return translate('report.actions.type.exportedToCSV'); case CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE: { const {result, label} = originalMessage; const errorMessage = result?.messages?.join(', ') ?? ''; const linkText = result?.link?.text ?? ''; const linkURL = result?.link?.url ?? ''; if (errorMessage.includes(CONST.ERROR.INTEGRATION_MESSAGE_INVALID_CREDENTIALS)) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const translateErrorMessage = translateLocal('report.actions.error.invalidCredentials'); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const translateLinkText = translateLocal('report.connectionSettings'); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.integrationsMessage', {errorMessage: translateErrorMessage, label, linkText: translateLinkText, linkURL}); + const translateErrorMessage = translate('report.actions.error.invalidCredentials'); + const translateLinkText = translate('report.connectionSettings'); + return translate('report.actions.type.integrationsMessage', {errorMessage: translateErrorMessage, label, linkText: translateLinkText, linkURL}); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.integrationsMessage', {errorMessage, label, linkText, linkURL}); + return translate('report.actions.type.integrationsMessage', {errorMessage, label, linkText, linkURL}); } case CONST.REPORT.ACTIONS.TYPE.MANAGER_ATTACH_RECEIPT: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.managerAttachReceipt'); + return translate('report.actions.type.managerAttachReceipt'); case CONST.REPORT.ACTIONS.TYPE.MANAGER_DETACH_RECEIPT: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.managerDetachReceipt'); + return translate('report.actions.type.managerDetachReceipt'); case CONST.REPORT.ACTIONS.TYPE.MARK_REIMBURSED_FROM_INTEGRATION: { const {amount, currency} = originalMessage; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.markedReimbursedFromIntegration', {amount, currency}); + return translate('report.actions.type.markedReimbursedFromIntegration', {amount, currency}); } case CONST.REPORT.ACTIONS.TYPE.OUTDATED_BANK_ACCOUNT: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.outdatedBankAccount'); + return translate('report.actions.type.outdatedBankAccount'); case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_BOUNCE: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.reimbursementACHBounce'); + return translate('report.actions.type.reimbursementACHBounce'); case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACH_CANCELED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.reimbursementACHCancelled'); + return translate('report.actions.type.reimbursementACHCancelled'); case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_ACCOUNT_CHANGED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.reimbursementAccountChanged'); + return translate('report.actions.type.reimbursementAccountChanged'); case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DELAYED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.reimbursementDelayed'); + return translate('report.actions.type.reimbursementDelayed'); case CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal(`report.actions.type.selectedForRandomAudit${withMarkdown ? 'Markdown' : ''}`); + return translate(`report.actions.type.selectedForRandomAudit${withMarkdown ? 'Markdown' : ''}`); case CONST.REPORT.ACTIONS.TYPE.SHARE: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.share', {to: originalMessage.to}); + return translate('report.actions.type.share', {to: originalMessage.to}); case CONST.REPORT.ACTIONS.TYPE.UNSHARE: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.unshare', {to: originalMessage.to}); + return translate('report.actions.type.unshare', {to: originalMessage.to}); case CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.takeControl'); + return translate('report.actions.type.takeControl'); default: return ''; } } -function getTravelUpdateMessage(action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, formatDate?: (datetime: string, includeTimezone: boolean, isLowercase?: boolean | undefined) => string) { +function getTravelUpdateMessage( + translate: LocalizedTranslate, + action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, + formatDate?: (datetime: string, includeTimezone: boolean, isLowercase?: boolean | undefined) => string, +) { const details = getOriginalMessage(action); const formattedStartDate = formatDate?.(details?.start.date ?? '', false) ?? format(details?.start.date ?? '', CONST.DATE.FNS_DATE_TIME_FORMAT_STRING); switch (details?.operation) { case CONST.TRAVEL.UPDATE_OPERATION_TYPE.BOOKING_TICKETED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.bookingTicketed', { + return translate('travel.updates.bookingTicketed', { airlineCode: details.route?.airlineCode ?? '', origin: details.start.shortName ?? '', destination: details.end?.shortName ?? '', @@ -1820,8 +1803,7 @@ function getTravelUpdateMessage(action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.TICKET_VOIDED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.ticketVoided', { + return translate('travel.updates.ticketVoided', { airlineCode: details.route?.airlineCode ?? '', origin: details.start.shortName ?? '', destination: details.end?.shortName ?? '', @@ -1829,8 +1811,7 @@ function getTravelUpdateMessage(action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.TICKET_REFUNDED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.ticketRefunded', { + return translate('travel.updates.ticketRefunded', { airlineCode: details.route?.airlineCode ?? '', origin: details.start.shortName ?? '', destination: details.end?.shortName ?? '', @@ -1838,8 +1819,7 @@ function getTravelUpdateMessage(action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.FLIGHT_CANCELLED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightCancelled', { + return translate('travel.updates.flightCancelled', { airlineCode: details.route?.airlineCode ?? '', origin: details.start.shortName ?? '', destination: details.end?.shortName ?? '', @@ -1847,16 +1827,13 @@ function getTravelUpdateMessage(action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.FLIGHT_SCHEDULE_CHANGE_PENDING: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightScheduleChangePending', details.route?.airlineCode ?? ''); + return translate('travel.updates.flightScheduleChangePending', details.route?.airlineCode ?? ''); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.FLIGHT_SCHEDULE_CHANGE_CLOSED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightScheduleChangeClosed', details.route?.airlineCode ?? '', formattedStartDate); + return translate('travel.updates.flightScheduleChangeClosed', details.route?.airlineCode ?? '', formattedStartDate); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.FLIGHT_CHANGED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightUpdated', { + return translate('travel.updates.flightUpdated', { airlineCode: details.route?.airlineCode ?? '', origin: details.start.shortName ?? '', destination: details.end?.shortName ?? '', @@ -1864,69 +1841,57 @@ function getTravelUpdateMessage(action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.FLIGHT_CABIN_CHANGED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightCabinChanged', details.route?.airlineCode ?? '', details.route?.class ?? ''); + return translate('travel.updates.flightCabinChanged', details.route?.airlineCode ?? '', details.route?.class ?? ''); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.FLIGHT_SEAT_CONFIRMED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightSeatConfirmed', details.route?.airlineCode ?? ''); + return translate('travel.updates.flightSeatConfirmed', details.route?.airlineCode ?? ''); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.FLIGHT_SEAT_CHANGED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightSeatChanged', details.route?.airlineCode ?? ''); + return translate('travel.updates.flightSeatChanged', details.route?.airlineCode ?? ''); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.FLIGHT_SEAT_CANCELLED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightSeatCancelled', details.route?.airlineCode ?? ''); + return translate('travel.updates.flightSeatCancelled', details.route?.airlineCode ?? ''); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.PAYMENT_DECLINED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.paymentDeclined'); + return translate('travel.updates.paymentDeclined'); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.BOOKING_CANCELED_BY_TRAVELER: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.bookingCancelledByTraveler', { + return translate('travel.updates.bookingCancelledByTraveler', { type: details.type, id: details.reservationID, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.BOOKING_CANCELED_BY_VENDOR: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.bookingCancelledByVendor', { + return translate('travel.updates.bookingCancelledByVendor', { type: details.type, id: details.reservationID, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.BOOKING_REBOOKED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.bookingRebooked', { + return translate('travel.updates.bookingRebooked', { type: details.type, id: details.confirmations?.at(0)?.value, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.BOOKING_UPDATED: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.bookingUpdated', { + return translate('travel.updates.bookingUpdated', { type: details.type, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.TRIP_UPDATED: if (details.type === CONST.RESERVATION_TYPE.CAR || details.type === CONST.RESERVATION_TYPE.HOTEL) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.defaultUpdate', { + return translate('travel.updates.defaultUpdate', { type: details.type, }); } if (details.type === CONST.RESERVATION_TYPE.TRAIN) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.railTicketUpdate', { + return translate('travel.updates.railTicketUpdate', { origin: details.start.cityName ?? details.start.shortName ?? '', destination: details.end.cityName ?? details.end.shortName ?? '', startDate: formattedStartDate, }); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightUpdated', { + return translate('travel.updates.flightUpdated', { airlineCode: details.route?.airlineCode ?? '', origin: details.start.shortName ?? '', destination: details.end?.shortName ?? '', @@ -1934,21 +1899,18 @@ function getTravelUpdateMessage(action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.BOOKING_OTHER_UPDATE: if (details.type === CONST.RESERVATION_TYPE.CAR || details.type === CONST.RESERVATION_TYPE.HOTEL) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.defaultUpdate', { + return translate('travel.updates.defaultUpdate', { type: details.type, }); } if (details.type === CONST.RESERVATION_TYPE.TRAIN) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.railTicketUpdate', { + return translate('travel.updates.railTicketUpdate', { origin: details.start.cityName ?? details.start.shortName ?? '', destination: details.end.cityName ?? details.end.shortName ?? '', startDate: formattedStartDate, }); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.flightUpdated', { + return translate('travel.updates.flightUpdated', { airlineCode: details.route?.airlineCode ?? '', origin: details.start.shortName ?? '', destination: details.end?.shortName ?? '', @@ -1956,32 +1918,29 @@ function getTravelUpdateMessage(action: ReportAction<'TRAVEL_TRIP_ROOM_UPDATE'>, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.REFUND: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.railTicketRefund', { + return translate('travel.updates.railTicketRefund', { origin: details.start.cityName ?? details.start.shortName ?? '', destination: details.end.cityName ?? details.end.shortName ?? '', startDate: formattedStartDate, }); case CONST.TRAVEL.UPDATE_OPERATION_TYPE.EXCHANGE: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.railTicketExchange', { + return translate('travel.updates.railTicketExchange', { origin: details.start.cityName ?? details.start.shortName ?? '', destination: details.end.cityName ?? details.end.shortName ?? '', startDate: formattedStartDate, }); default: - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('travel.updates.defaultUpdate', { + return translate('travel.updates.defaultUpdate', { type: details?.type ?? '', }); } } // eslint-disable-next-line @typescript-eslint/no-deprecated -function getMemberChangeMessageFragment(reportAction: OnyxEntry, getReportNameCallback: typeof getReportName): Message { - const messageElements: readonly MemberChangeMessageElement[] = getMemberChangeMessageElements(reportAction, getReportNameCallback); +function getMemberChangeMessageFragment(translate: LocalizedTranslate, reportAction: OnyxEntry, getReportNameCallback: typeof getReportName): Message { + const messageElements: readonly MemberChangeMessageElement[] = getMemberChangeMessageElements(translate, reportAction, getReportNameCallback); const html = messageElements .map((messageElement) => { switch (messageElement.kind) { @@ -2002,23 +1961,8 @@ function getMemberChangeMessageFragment(reportAction: OnyxEntry, g }; } -function getLeaveRoomMessage() { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.leftTheChat'); -} - -function getReopenedMessage(): string { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('iou.reopened'); -} - -function getReceiptScanFailedMessage() { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('iou.receiptScanningFailed'); -} - -function getUpdateRoomDescriptionFragment(reportAction: ReportAction): Message { - const html = getUpdateRoomDescriptionMessage(reportAction); +function getUpdateRoomDescriptionFragment(translate: LocalizedTranslate, reportAction: ReportAction): Message { + const html = getUpdateRoomDescriptionMessage(translate, reportAction); return { html: `${html}`, text: getReportActionMessage(reportAction) ? getReportActionText(reportAction) : '', @@ -2026,25 +1970,25 @@ function getUpdateRoomDescriptionFragment(reportAction: ReportAction): Message { }; } -function getReportActionMessageFragments(action: ReportAction): Message[] { +function getReportActionMessageFragments(translate: LocalizedTranslate, action: ReportAction): Message[] { if (isOldDotReportAction(action)) { - const oldDotMessage = getMessageOfOldDotReportAction(action); + const oldDotMessage = getMessageOfOldDotReportAction(translate, action); const html = isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT) ? Parser.replace(oldDotMessage) : oldDotMessage; return [{text: oldDotMessage, html: `${html}`, type: 'COMMENT'}]; } if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION)) { - const message = getUpdateRoomDescriptionMessage(action); + const message = getUpdateRoomDescriptionMessage(translate, action); return [{text: message, html: `${message}`, type: 'COMMENT'}]; } if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_AVATAR)) { - const message = getRoomAvatarUpdatedMessage(action); + const message = getRoomAvatarUpdatedMessage(translate, action); return [{text: message, html: `${message}`, type: 'COMMENT'}]; } if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION)) { - const message = getWorkspaceDescriptionUpdatedMessage(action); + const message = getWorkspaceDescriptionUpdatedMessage(translate, action); return [{text: message, html: `${message}`, type: 'COMMENT'}]; } @@ -2054,17 +1998,17 @@ function getReportActionMessageFragments(action: ReportAction): Message[] { } if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.RETRACTED)) { - const message = getRetractedMessage(); + const message = translate('iou.retracted'); return [{text: message, html: `${message}`, type: 'COMMENT'}]; } if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REOPENED)) { - const message = getReopenedMessage(); + const message = translate('iou.reopened'); return [{text: message, html: `${message}`, type: 'COMMENT'}]; } if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) { - const message = getTravelUpdateMessage(action); + const message = getTravelUpdateMessage(translate, action); return [{text: message, html: `${message}`, type: 'COMMENT'}]; } @@ -2074,8 +2018,7 @@ function getReportActionMessageFragments(action: ReportAction): Message[] { } if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED)) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - const message = getDynamicExternalWorkflowRoutedMessage(action, translateLocal); + const message = getDynamicExternalWorkflowRoutedMessage(action, translate); return [{text: message, html: `${message}`, type: 'COMMENT'}]; } @@ -2111,7 +2054,7 @@ function hasRequestFromCurrentAccount(reportID: string | undefined, currentAccou * @param reportAction * @returns the actionable mention whisper message. */ -function getActionableMentionWhisperMessage(reportAction: OnyxEntry>): string { +function getActionableMentionWhisperMessage(translate: LocalizedTranslate, reportAction: OnyxEntry>): string { if (!reportAction) { return ''; } @@ -2121,8 +2064,7 @@ function getActionableMentionWhisperMessage(reportAction: OnyxEntry { const personalDetail = personalDetails.find((personal) => personal.accountID === accountID); const displayName = getEffectiveDisplayName(formatPhoneNumber, personalDetail); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const handleText = isEmpty(displayName) ? translateLocal('common.hidden') : displayName; + const handleText = isEmpty(displayName) ? translate('common.hidden') : displayName; return `@${handleText}`; }); const preMentionsText = 'Heads up, '; @@ -2208,11 +2150,10 @@ function getReportActionMessageText(reportAction: OnyxEntry): stri return reportAction?.message?.reduce((acc, curr) => `${acc}${getTextFromHtml(curr?.html || curr?.text)}`, '') ?? ''; } -function getDismissedViolationMessageText(originalMessage: ReportAction['originalMessage']): string { +function getDismissedViolationMessageText(translate: LocalizedTranslate, originalMessage: ReportAction['originalMessage']): string { const reason = originalMessage?.reason; const violationName = originalMessage?.violationName; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal(`violationDismissal.${violationName}.${reason}` as TranslationPaths); + return translate(`violationDismissal.${violationName}.${reason}` as TranslationPaths); } function getMentionedAccountIDsFromAction(reportAction: OnyxInputOrEntry) { @@ -2287,18 +2228,18 @@ function isActionableCardFraudAlert(reportAction: OnyxInputOrEntry return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT; } -function getExportIntegrationLastMessageText(reportAction: OnyxEntry): string { - const fragments = getExportIntegrationActionFragments(reportAction); +function getExportIntegrationLastMessageText(translate: LocalizedTranslate, reportAction: OnyxEntry): string { + const fragments = getExportIntegrationActionFragments(translate, reportAction); return fragments.reduce((acc, fragment) => `${acc} ${fragment.text}`, ''); } -function getExportIntegrationMessageHTML(reportAction: OnyxEntry): string { - const fragments = getExportIntegrationActionFragments(reportAction); +function getExportIntegrationMessageHTML(translate: LocalizedTranslate, reportAction: OnyxEntry): string { + const fragments = getExportIntegrationActionFragments(translate, reportAction); const htmlFragments = fragments.map((fragment) => (fragment.url ? `${fragment.text}` : fragment.text)); return htmlFragments.join(' '); } -function getExportIntegrationActionFragments(reportAction: OnyxEntry): Array<{text: string; url: string}> { +function getExportIntegrationActionFragments(translate: LocalizedTranslate, reportAction: OnyxEntry): Array<{text: string; url: string}> { if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) { throw Error(`received wrong action type. actionName: ${reportAction?.actionName}`); } @@ -2315,39 +2256,33 @@ function getExportIntegrationActionFragments(reportAction: OnyxEntry = []; if (isPending) { result.push({ - // eslint-disable-next-line @typescript-eslint/no-deprecated - text: translateLocal('report.actions.type.exportedToIntegration.pending', {label}), + text: translate('report.actions.type.exportedToIntegration.pending', {label}), url: '', }); } else if (markedManually) { result.push({ - // eslint-disable-next-line @typescript-eslint/no-deprecated - text: translateLocal('report.actions.type.exportedToIntegration.manual', {label}), + text: translate('report.actions.type.exportedToIntegration.manual', {label}), url: '', }); } else if (automaticAction) { result.push({ - // eslint-disable-next-line @typescript-eslint/no-deprecated - text: translateLocal('report.actions.type.exportedToIntegration.automaticActionOne', {label}), + text: translate('report.actions.type.exportedToIntegration.automaticActionOne', {label}), url: '', }); const url = CONST.HELP_DOC_LINKS[label as keyof typeof CONST.HELP_DOC_LINKS]; result.push({ - // eslint-disable-next-line @typescript-eslint/no-deprecated - text: translateLocal('report.actions.type.exportedToIntegration.automaticActionTwo'), + text: translate('report.actions.type.exportedToIntegration.automaticActionTwo'), url: url || '', }); } else { result.push({ - // eslint-disable-next-line @typescript-eslint/no-deprecated - text: translateLocal('report.actions.type.exportedToIntegration.automatic', {label}), + text: translate('report.actions.type.exportedToIntegration.automatic', {label}), url: '', }); } if (reimbursableUrls.length || nonReimbursableUrls.length) { result.push({ - // eslint-disable-next-line @typescript-eslint/no-deprecated - text: translateLocal('report.actions.type.exportedToIntegration.automaticActionThree'), + text: translate('report.actions.type.exportedToIntegration.automaticActionThree'), url: '', }); } @@ -2356,21 +2291,18 @@ function getExportIntegrationActionFragments(reportAction: OnyxEntry): reportAction is ReportAction { return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE); } -function getPolicyChangeLogAddEmployeeMessage(reportAction: OnyxInputOrEntry): string { +function getPolicyChangeLogAddEmployeeMessage(translate: LocalizedTranslate, reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogAddEmployeeMessage(reportAction)) { return ''; } const originalMessage = getOriginalMessage(reportAction); const email = originalMessage?.email ?? ''; - // eslint-disable-next-line @typescript-eslint/no-deprecated - const role = translateLocal('workspace.common.roleName', {role: originalMessage?.role ?? ''}).toLowerCase(); + const role = translate('workspace.common.roleName', {role: originalMessage?.role ?? ''}).toLowerCase(); const formattedEmail = formatPhoneNumber(email); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.addEmployee', formattedEmail, role); + return translate('report.actions.type.addEmployee', formattedEmail, role); } function isPolicyChangeLogChangeRoleMessage(reportAction: OnyxInputOrEntry): reportAction is ReportAction { return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE); } -function buildPolicyChangeLogUpdateEmployeeSingleFieldMessage(field: string | undefined, oldValue: unknown, newValue: unknown, rawEmail: string): string { +function buildPolicyChangeLogUpdateEmployeeSingleFieldMessage(translate: LocalizedTranslate, field: string | undefined, oldValue: unknown, newValue: unknown, rawEmail: string): string { if (!field) { return ''; } @@ -2459,23 +2380,19 @@ function buildPolicyChangeLogUpdateEmployeeSingleFieldMessage(field: string | un const customFieldType = Object.values(CONST.CUSTOM_FIELD_KEYS).find((value) => value === field); if (customFieldType) { const translationKey = field === CONST.CUSTOM_FIELD_KEYS.customField1 ? 'report.actions.type.updatedCustomField1' : 'report.actions.type.updatedCustomField2'; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal(translationKey, { + return translate(translationKey, { email, newValue: stringNewValue, previousValue: stringOldValue, }); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - const newRole = translateLocal('workspace.common.roleName', {role: stringNewValue}).toLowerCase(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const oldRole = translateLocal('workspace.common.roleName', {role: stringOldValue}).toLowerCase(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.updateRole', {email, newRole, currentRole: oldRole}); + const newRole = translate('workspace.common.roleName', {role: stringNewValue}).toLowerCase(); + const oldRole = translate('workspace.common.roleName', {role: stringOldValue}).toLowerCase(); + return translate('report.actions.type.updateRole', {email, newRole, currentRole: oldRole}); } -function getPolicyChangeLogUpdateEmployee(reportAction: OnyxInputOrEntry): string { +function getPolicyChangeLogUpdateEmployee(translate: LocalizedTranslate, reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogChangeRoleMessage(reportAction)) { return ''; } @@ -2490,17 +2407,17 @@ function getPolicyChangeLogUpdateEmployee(reportAction: OnyxInputOrEntry) ?? {}; const message = - // eslint-disable-next-line @typescript-eslint/no-deprecated - typeof oldDescription === 'string' && newDescription ? translateLocal('workspaceActions.updateWorkspaceDescription', {newDescription, oldDescription}) : getReportActionText(action); + typeof oldDescription === 'string' && newDescription ? translate('workspaceActions.updateWorkspaceDescription', {newDescription, oldDescription}) : getReportActionText(action); return message; } -function getWorkspaceCurrencyUpdateMessage(action: ReportAction) { +function getWorkspaceCurrencyUpdateMessage(translate: LocalizedTranslate, action: ReportAction) { const {oldCurrency, newCurrency} = getOriginalMessage(action as ReportAction) ?? {}; - // eslint-disable-next-line @typescript-eslint/no-deprecated - const message = oldCurrency && newCurrency ? translateLocal('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : getReportActionText(action); + const message = oldCurrency && newCurrency ? translate('workspaceActions.updatedWorkspaceCurrencyAction', {oldCurrency, newCurrency}) : getReportActionText(action); return message; } type AutoReportingFrequencyKey = ValueOf; type AutoReportingFrequencyDisplayNames = Record; -const getAutoReportingFrequencyDisplayNames = (): AutoReportingFrequencyDisplayNames => ({ - // eslint-disable-next-line @typescript-eslint/no-deprecated - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: translateLocal('workflowsPage.frequencies.monthly'), - // eslint-disable-next-line @typescript-eslint/no-deprecated - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: translateLocal('workflowsPage.frequencies.daily'), - // eslint-disable-next-line @typescript-eslint/no-deprecated - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: translateLocal('workflowsPage.frequencies.weekly'), - // eslint-disable-next-line @typescript-eslint/no-deprecated - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: translateLocal('workflowsPage.frequencies.twiceAMonth'), - // eslint-disable-next-line @typescript-eslint/no-deprecated - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: translateLocal('workflowsPage.frequencies.byTrip'), - // eslint-disable-next-line @typescript-eslint/no-deprecated - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: translateLocal('workflowsPage.frequencies.manually'), - // eslint-disable-next-line @typescript-eslint/no-deprecated - [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: translateLocal('workflowsPage.frequencies.instant'), +const getAutoReportingFrequencyDisplayNames = (translate: LocalizedTranslate): AutoReportingFrequencyDisplayNames => ({ + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MONTHLY]: translate('workflowsPage.frequencies.monthly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.IMMEDIATE]: translate('workflowsPage.frequencies.daily'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY]: translate('workflowsPage.frequencies.weekly'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.SEMI_MONTHLY]: translate('workflowsPage.frequencies.twiceAMonth'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.TRIP]: translate('workflowsPage.frequencies.byTrip'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL]: translate('workflowsPage.frequencies.manually'), + [CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT]: translate('workflowsPage.frequencies.instant'), }); -function getWorkspaceFrequencyUpdateMessage(action: ReportAction): string { +function getWorkspaceFrequencyUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldFrequency, newFrequency} = getOriginalMessage(action as ReportAction) ?? {}; if (!oldFrequency || !newFrequency) { return getReportActionText(action); } - const frequencyDisplayNames = getAutoReportingFrequencyDisplayNames(); + const frequencyDisplayNames = getAutoReportingFrequencyDisplayNames(translate); const oldFrequencyTranslation = frequencyDisplayNames[oldFrequency]?.toLowerCase(); const newFrequencyTranslation = frequencyDisplayNames[newFrequency]?.toLowerCase(); if (!oldFrequencyTranslation || !newFrequencyTranslation) { return getReportActionText(action); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedWorkspaceFrequencyAction', { + return translate('workspaceActions.updatedWorkspaceFrequencyAction', { oldFrequency: oldFrequencyTranslation, newFrequency: newFrequencyTranslation, }); } -function getWorkspaceCategoryUpdateMessage(action: ReportAction, policy?: OnyxEntry): string { +function getWorkspaceCategoryUpdateMessage(translate: LocalizedTranslate, action: ReportAction, policy?: OnyxEntry): string { const {categoryName, oldValue, newName, oldName, updatedField, newValue, currency} = getOriginalMessage(action as ReportAction) ?? {}; const decodedOptionName = getDecodedCategoryName(categoryName ?? ''); if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY && categoryName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.addCategory', { + return translate('workspaceActions.addCategory', { categoryName: decodedOptionName, }); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY && categoryName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.deleteCategory', { + return translate('workspaceActions.deleteCategory', { categoryName: decodedOptionName, }); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY && categoryName) { if (updatedField === 'commentHint') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedDescriptionHint', { + return translate('workspaceActions.updatedDescriptionHint', { oldValue: oldValue as string | undefined, newValue: newValue as string | undefined, categoryName: decodedOptionName, @@ -2608,24 +2511,21 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction, policy?: OnyxEn } if (updatedField === 'enabled') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCategory', { + return translate('workspaceActions.updateCategory', { oldValue: !!oldValue, categoryName: decodedOptionName, }); } if (updatedField === 'areCommentsRequired' && typeof oldValue === 'boolean') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateAreCommentsRequired', { + return translate('workspaceActions.updateAreCommentsRequired', { oldValue, categoryName: decodedOptionName, }); } if (updatedField === 'Payroll Code' && typeof oldValue === 'string' && typeof newValue === 'string') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCategoryPayrollCode', { + return translate('workspaceActions.updateCategoryPayrollCode', { oldValue, categoryName: decodedOptionName, newValue, @@ -2633,8 +2533,7 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction, policy?: OnyxEn } if (updatedField === 'GL Code' && typeof oldValue === 'string' && typeof newValue === 'string') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCategoryGLCode', { + return translate('workspaceActions.updateCategoryGLCode', { oldValue, categoryName: decodedOptionName, newValue, @@ -2642,8 +2541,7 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction, policy?: OnyxEn } if (updatedField === 'maxExpenseAmount' && (typeof oldValue === 'string' || typeof oldValue === 'number')) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCategoryMaxExpenseAmount', { + return translate('workspaceActions.updateCategoryMaxExpenseAmount', { oldAmount: Number(oldValue) ? convertAmountToDisplayString(Number(oldValue), currency) : undefined, newAmount: Number(newValue ?? 0) ? convertAmountToDisplayString(Number(newValue), currency) : undefined, categoryName: decodedOptionName, @@ -2651,13 +2549,10 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction, policy?: OnyxEn } if (updatedField === 'expenseLimitType' && typeof newValue === 'string' && typeof oldValue === 'string') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCategoryExpenseLimitType', { + return translate('workspaceActions.updateCategoryExpenseLimitType', { categoryName: decodedOptionName, - // eslint-disable-next-line @typescript-eslint/no-deprecated - oldValue: oldValue ? translateLocal(`workspace.rules.categoryRules.expenseLimitTypes.${oldValue}` as TranslationPaths) : undefined, - // eslint-disable-next-line @typescript-eslint/no-deprecated - newValue: translateLocal(`workspace.rules.categoryRules.expenseLimitTypes.${newValue}` as TranslationPaths), + oldValue: oldValue ? translate(`workspace.rules.categoryRules.expenseLimitTypes.${oldValue}` as TranslationPaths) : undefined, + newValue: translate(`workspace.rules.categoryRules.expenseLimitTypes.${newValue}` as TranslationPaths), }); } @@ -2667,18 +2562,14 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction, policy?: OnyxEn const formatAmount = () => convertToShortDisplayString(maxExpenseAmountToDisplay, policy?.outputCurrency ?? CONST.CURRENCY.USD); const getTranslation = (value?: number | string) => { if (value === CONST.DISABLED_MAX_EXPENSE_VALUE) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspace.rules.categoryRules.requireReceiptsOverList.never'); + return translate('workspace.rules.categoryRules.requireReceiptsOverList.never'); } if (value === 0) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspace.rules.categoryRules.requireReceiptsOverList.always'); + return translate('workspace.rules.categoryRules.requireReceiptsOverList.always'); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspace.rules.categoryRules.requireReceiptsOverList.default', formatAmount()); + return translate('workspace.rules.categoryRules.requireReceiptsOverList.default', formatAmount()); }; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCategoryMaxAmountNoReceipt', { + return translate('workspaceActions.updateCategoryMaxAmountNoReceipt', { categoryName: decodedOptionName, oldValue: getTranslation(oldValue), newValue: getTranslation(newValue), @@ -2687,8 +2578,7 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction, policy?: OnyxEn } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME && oldName && newName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.setCategoryName', { + return translate('workspaceActions.setCategoryName', { oldName: getDecodedCategoryName(oldName), newName: getDecodedCategoryName(newName), }); @@ -2697,91 +2587,81 @@ function getWorkspaceCategoryUpdateMessage(action: ReportAction, policy?: OnyxEn return getReportActionText(action); } -function getWorkspaceTaxUpdateMessage(action: ReportAction): string { +function getWorkspaceTaxUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const {taxName, oldValue, newValue, updatedField} = getOriginalMessage(action as ReportAction) ?? {}; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAX && taxName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.addTax', {taxName}); + return translate('workspaceActions.addTax', {taxName}); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAX && taxName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.deleteTax', {taxName}); + return translate('workspaceActions.deleteTax', {taxName}); } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAX && taxName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateTax', {taxName, oldValue, newValue, updatedField}); + return translate('workspaceActions.updateTax', {taxName, oldValue, newValue, updatedField}); } return getReportActionText(action); } -function getCustomTaxNameUpdateMessage(action: ReportAction): string { +function getCustomTaxNameUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldName = '', newName} = getOriginalMessage(action as ReportAction) ?? {}; if (newName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCustomTaxName', {oldName, newName}); + return translate('workspaceActions.updateCustomTaxName', {oldName, newName}); } return getReportActionText(action); } -function getCurrencyDefaultTaxUpdateMessage(action: ReportAction): string { +function getCurrencyDefaultTaxUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldName = '', newName} = getOriginalMessage(action as ReportAction) ?? {}; if (newName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCurrencyDefaultTax', {oldName, newName}); + return translate('workspaceActions.updateCurrencyDefaultTax', {oldName, newName}); } return getReportActionText(action); } -function getForeignCurrencyDefaultTaxUpdateMessage(action: ReportAction): string { +function getForeignCurrencyDefaultTaxUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldName = '', newName} = getOriginalMessage(action as ReportAction) ?? {}; if (newName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateForeignCurrencyDefaultTax', {oldName, newName}); + return translate('workspaceActions.updateForeignCurrencyDefaultTax', {oldName, newName}); } return getReportActionText(action); } -function getWorkspaceTagUpdateMessage(action: ReportAction | undefined): string { +function getWorkspaceTagUpdateMessage(translate: LocalizedTranslate, action: ReportAction | undefined): string { const {tagListName, tagName, enabled, newName, newValue, oldName, oldValue, updatedField, count} = getOriginalMessage(action as ReportAction) ?? {}; if (action?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAG && tagListName && tagName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.addTag', { + return translate('workspaceActions.addTag', { tagListName, tagName, }); } if (action?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAG && tagListName && tagName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.deleteTag', { + return translate('workspaceActions.deleteTag', { tagListName, tagName, }); } if (action?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_MULTIPLE_TAGS && count && tagListName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.deleteMultipleTags', { + return translate('workspaceActions.deleteMultipleTags', { count, tagListName, }); } if (action?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_ENABLED && tagListName && tagName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateTagEnabled', { + return translate('workspaceActions.updateTagEnabled', { tagListName, tagName, enabled, @@ -2789,8 +2669,7 @@ function getWorkspaceTagUpdateMessage(action: ReportAction | undefined): string } if (action?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_NAME && tagListName && newName && oldName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateTagName', { + return translate('workspaceActions.updateTagName', { tagListName, newName, oldName, @@ -2805,8 +2684,7 @@ function getWorkspaceTagUpdateMessage(action: ReportAction | undefined): string tagName && updatedField ) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateTag', { + return translate('workspaceActions.updateTag', { tagListName, oldValue, newValue, @@ -2818,11 +2696,10 @@ function getWorkspaceTagUpdateMessage(action: ReportAction | undefined): string return getReportActionText(action); } -function getTagListNameUpdatedMessage(action: ReportAction): string { +function getTagListNameUpdatedMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldName, newName} = getOriginalMessage(action as ReportAction) ?? {}; if (newName && oldName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateTagListName', { + return translate('workspaceActions.updateTagListName', { oldName, newName, }); @@ -2830,19 +2707,17 @@ function getTagListNameUpdatedMessage(action: ReportAction): string { return getReportActionText(action); } -function getWorkspaceCustomUnitUpdatedMessage(action: ReportAction): string { +function getWorkspaceCustomUnitUpdatedMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldValue, newValue, customUnitName, updatedField} = getOriginalMessage(action as ReportAction) ?? {}; if (customUnitName === 'Distance' && updatedField === 'taxEnabled' && typeof newValue === 'boolean') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCustomUnitTaxEnabled', { + return translate('workspaceActions.updateCustomUnitTaxEnabled', { newValue, }); } if (customUnitName && typeof oldValue === 'string' && typeof newValue === 'string' && updatedField) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateCustomUnit', { + return translate('workspaceActions.updateCustomUnit', { customUnitName, newValue, oldValue, @@ -2853,24 +2728,22 @@ function getWorkspaceCustomUnitUpdatedMessage(action: ReportAction): string { return getReportActionText(action); } -function getWorkspaceCustomUnitRateAddedMessage(action: ReportAction): string { +function getWorkspaceCustomUnitRateAddedMessage(translate: LocalizedTranslate, action: ReportAction): string { const {customUnitName, rateName} = getOriginalMessage(action as ReportAction) ?? {}; if (customUnitName && rateName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.addCustomUnitRate', customUnitName, rateName); + return translate('workspaceActions.addCustomUnitRate', customUnitName, rateName); } return getReportActionText(action); } -function getWorkspaceCustomUnitRateUpdatedMessage(action: ReportAction): string { +function getWorkspaceCustomUnitRateUpdatedMessage(translate: LocalizedTranslate, action: ReportAction): string { const {customUnitName, customUnitRateName, updatedField, oldValue, newValue, newTaxPercentage, oldTaxPercentage} = getOriginalMessage(action as ReportAction) ?? {}; if (customUnitName && customUnitRateName && updatedField === 'rate' && typeof oldValue === 'string' && typeof newValue === 'string') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedCustomUnitRate', { + return translate('workspaceActions.updatedCustomUnitRate', { customUnitName, customUnitRateName, updatedField, @@ -2880,8 +2753,7 @@ function getWorkspaceCustomUnitRateUpdatedMessage(action: ReportAction): string } if (customUnitRateName && updatedField === 'taxRateExternalID' && typeof newValue === 'string' && newTaxPercentage) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedCustomUnitTaxRateExternalID', { + return translate('workspaceActions.updatedCustomUnitTaxRateExternalID', { customUnitRateName, newValue, newTaxPercentage, @@ -2891,8 +2763,7 @@ function getWorkspaceCustomUnitRateUpdatedMessage(action: ReportAction): string } if (customUnitRateName && updatedField === 'taxClaimablePercentage' && typeof newValue === 'number' && customUnitRateName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedCustomUnitTaxClaimablePercentage', { + return translate('workspaceActions.updatedCustomUnitTaxClaimablePercentage', { customUnitRateName, newValue: parseFloat(parseFloat(newValue ?? 0).toFixed(2)), oldValue: typeof oldValue === 'number' ? parseFloat(parseFloat(oldValue ?? 0).toFixed(2)) : undefined, @@ -2900,8 +2771,7 @@ function getWorkspaceCustomUnitRateUpdatedMessage(action: ReportAction): string } if (customUnitName && customUnitRateName && updatedField === 'index' && typeof newValue === 'number') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedCustomUnitRateIndex', { + return translate('workspaceActions.updatedCustomUnitRateIndex', { customUnitName, customUnitRateName, oldValue: oldValue ? Number(oldValue) : undefined, @@ -2910,8 +2780,7 @@ function getWorkspaceCustomUnitRateUpdatedMessage(action: ReportAction): string } if (customUnitName && customUnitRateName && updatedField === 'enabled' && typeof oldValue === 'boolean' && typeof newValue === 'boolean') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedCustomUnitRateEnabled', { + return translate('workspaceActions.updatedCustomUnitRateEnabled', { customUnitName, customUnitRateName, oldValue, @@ -2922,50 +2791,45 @@ function getWorkspaceCustomUnitRateUpdatedMessage(action: ReportAction): string return getReportActionText(action); } -function getWorkspaceCustomUnitRateDeletedMessage(action: ReportAction): string { +function getWorkspaceCustomUnitRateDeletedMessage(translate: LocalizedTranslate, action: ReportAction): string { const {customUnitName, rateName} = getOriginalMessage(action as ReportAction) ?? {}; if (customUnitName && rateName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.deleteCustomUnitRate', customUnitName, rateName); + return translate('workspaceActions.deleteCustomUnitRate', customUnitName, rateName); } return getReportActionText(action); } -function getWorkspaceReportFieldAddMessage(action: ReportAction): string { +function getWorkspaceReportFieldAddMessage(translate: LocalizedTranslate, action: ReportAction): string { const {fieldName, fieldType} = getOriginalMessage(action as ReportAction) ?? {}; if (fieldName && fieldType) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.addedReportField', translateLocal(getReportFieldTypeTranslationKey(fieldType as PolicyReportFieldType)).toLowerCase(), fieldName); + return translate('workspaceActions.addedReportField', translate(getReportFieldTypeTranslationKey(fieldType as PolicyReportFieldType)).toLowerCase(), fieldName); } return getReportActionText(action); } -function getWorkspaceReportFieldUpdateMessage(action: ReportAction): string { +function getWorkspaceReportFieldUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const {updateType, fieldName, defaultValue, optionName, allEnabled, optionEnabled, toggledOptionsCount} = getOriginalMessage(action as ReportAction) ?? {}; if (updateType === 'updatedDefaultValue' && fieldName && defaultValue) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateReportFieldDefaultValue', { + return translate('workspaceActions.updateReportFieldDefaultValue', { fieldName, defaultValue, }); } if (updateType === 'addedOption' && fieldName && optionName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.addedReportFieldOption', { + return translate('workspaceActions.addedReportFieldOption', { fieldName, optionName, }); } if (updateType === 'changedOptionDisabled' && fieldName && optionName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateReportFieldOptionDisabled', { + return translate('workspaceActions.updateReportFieldOptionDisabled', { fieldName, optionName, optionEnabled: !!optionEnabled, @@ -2973,8 +2837,7 @@ function getWorkspaceReportFieldUpdateMessage(action: ReportAction): string { } if (updateType === 'updatedAllDisabled' && fieldName && optionName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateReportFieldAllOptionsDisabled', { + return translate('workspaceActions.updateReportFieldAllOptionsDisabled', { fieldName, optionName, allEnabled: !!allEnabled, @@ -2983,8 +2846,7 @@ function getWorkspaceReportFieldUpdateMessage(action: ReportAction): string { } if (updateType === 'removedOption' && fieldName && optionName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.removedReportFieldOption', { + return translate('workspaceActions.removedReportFieldOption', { fieldName, optionName, }); @@ -2993,45 +2855,39 @@ function getWorkspaceReportFieldUpdateMessage(action: ReportAction): string { return getReportActionText(action); } -function getWorkspaceReportFieldDeleteMessage(action: ReportAction): string { +function getWorkspaceReportFieldDeleteMessage(translate: LocalizedTranslate, action: ReportAction): string { const {fieldType, fieldName} = getOriginalMessage(action as ReportAction) ?? {}; if (fieldType && fieldName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.deleteReportField', translateLocal(getReportFieldTypeTranslationKey(fieldType as PolicyReportFieldType)).toLowerCase(), fieldName); + return translate('workspaceActions.deleteReportField', translate(getReportFieldTypeTranslationKey(fieldType as PolicyReportFieldType)).toLowerCase(), fieldName); } return getReportActionText(action); } -function getWorkspaceUpdateFieldMessage(action: ReportAction): string { +function getWorkspaceUpdateFieldMessage(translate: LocalizedTranslate, action: ReportAction): string { const {newValue, oldValue, updatedField} = getOriginalMessage(action as ReportAction) ?? {}; const newValueTranslationKey = CONST.POLICY.APPROVAL_MODE_TRANSLATION_KEYS[newValue as keyof typeof CONST.POLICY.APPROVAL_MODE_TRANSLATION_KEYS]; const oldValueTranslationKey = CONST.POLICY.APPROVAL_MODE_TRANSLATION_KEYS[oldValue as keyof typeof CONST.POLICY.APPROVAL_MODE_TRANSLATION_KEYS]; if (updatedField && updatedField === CONST.POLICY.COLLECTION_KEYS.APPROVAL_MODE && oldValueTranslationKey && newValueTranslationKey) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateApprovalMode', { - // eslint-disable-next-line @typescript-eslint/no-deprecated - newValue: translateLocal(`workspaceApprovalModes.${newValueTranslationKey}` as TranslationPaths), - // eslint-disable-next-line @typescript-eslint/no-deprecated - oldValue: translateLocal(`workspaceApprovalModes.${oldValueTranslationKey}` as TranslationPaths), + return translate('workspaceActions.updateApprovalMode', { + newValue: translate(`workspaceApprovalModes.${newValueTranslationKey}` as TranslationPaths), + oldValue: translate(`workspaceApprovalModes.${oldValueTranslationKey}` as TranslationPaths), fieldName: updatedField, }); } if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.PREVENT_SELF_APPROVAL && typeof oldValue === 'string' && typeof newValue === 'string') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.preventSelfApproval', { + return translate('workspaceActions.preventSelfApproval', { oldValue, newValue, }); } if (updatedField && updatedField === CONST.POLICY.EXPENSE_REPORT_RULES.MAX_EXPENSE_AGE && typeof oldValue === 'string' && typeof newValue === 'string') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateMaxExpenseAge', { + return translate('workspaceActions.updateMaxExpenseAge', { oldValue, newValue, }); @@ -3044,20 +2900,17 @@ function getWorkspaceUpdateFieldMessage(action: ReportAction): string { ) { const getAutoReportingOffsetToDisplay = (autoReportingOffset: string | number) => { if (autoReportingOffset === CONST.POLICY.AUTO_REPORTING_OFFSET.LAST_DAY_OF_MONTH) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workflowsPage.frequencies.lastDayOfMonth'); + return translate('workflowsPage.frequencies.lastDayOfMonth'); } if (autoReportingOffset === CONST.POLICY.AUTO_REPORTING_OFFSET.LAST_BUSINESS_DAY_OF_MONTH) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workflowsPage.frequencies.lastBusinessDayOfMonth'); + return translate('workflowsPage.frequencies.lastBusinessDayOfMonth'); } if (typeof autoReportingOffset === 'number') { return toLocaleOrdinal(IntlStore.getCurrentLocale(), autoReportingOffset, false); } return ''; }; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateMonthlyOffset', { + return translate('workspaceActions.updateMonthlyOffset', { newValue: getAutoReportingOffsetToDisplay(newValue), oldValue: getAutoReportingOffsetToDisplay(oldValue), }); @@ -3065,21 +2918,19 @@ function getWorkspaceUpdateFieldMessage(action: ReportAction): string { return getReportActionText(action); } -function getWorkspaceFeatureEnabledMessage(action: ReportAction): string { +function getWorkspaceFeatureEnabledMessage(translate: LocalizedTranslate, action: ReportAction): string { const {enabled, featureName} = getOriginalMessage(action as ReportAction) ?? {}; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedFeatureEnabled', { + return translate('workspaceActions.updatedFeatureEnabled', { enabled: !!enabled, featureName: featureName ?? '', }); } -function getWorkspaceAttendeeTrackingUpdateMessage(action: ReportAction): string { +function getWorkspaceAttendeeTrackingUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const {enabled} = getOriginalMessage(action as ReportAction) ?? {}; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedAttendeeTracking', {enabled: !!enabled}); + return translate('workspaceActions.updatedAttendeeTracking', {enabled: !!enabled}); } type DefaultApproverOriginalMessage = { @@ -3116,7 +2967,7 @@ function formatMemberListWithAnd(members: Array<{email: string; name: string}>): return `${allButLast.join(', ')}, and ${last}`; } -function getDefaultApproverUpdateMessage(action: ReportAction): string { +function getDefaultApproverUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const originalMessage = getOriginalMessage(action as ReportAction) as | DefaultApproverOriginalMessage | undefined; @@ -3127,11 +2978,10 @@ function getDefaultApproverUpdateMessage(action: ReportAction): string { const newApprover = formatPhoneNumber(originalMessage.approver?.email ?? ''); const previousApprover = originalMessage.previousApprover ? formatPhoneNumber(originalMessage.previousApprover.email) : undefined; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.changedDefaultApprover', {newApprover, previousApprover}); + return translate('workspaceActions.changedDefaultApprover', {newApprover, previousApprover}); } -function getSubmitsToUpdateMessage(action: ReportAction): string { +function getSubmitsToUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const originalMessage = getOriginalMessage(action as ReportAction) as SubmitsToOriginalMessage | undefined; if (!originalMessage) { @@ -3145,8 +2995,7 @@ function getSubmitsToUpdateMessage(action: ReportAction): string { const previousApproverEmail = originalMessage.previousApprover ? formatPhoneNumber(originalMessage.previousApprover.email) : undefined; if (isDefaultApprover) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.changedSubmitsToDefault', { + return translate('workspaceActions.changedSubmitsToDefault', { members, approver: approverEmail, previousApprover: previousApproverEmail, @@ -3154,8 +3003,7 @@ function getSubmitsToUpdateMessage(action: ReportAction): string { }); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.changedSubmitsToApprover', { + return translate('workspaceActions.changedSubmitsToApprover', { members, approver: approverEmail, previousApprover: previousApproverEmail, @@ -3163,7 +3011,7 @@ function getSubmitsToUpdateMessage(action: ReportAction): string { }); } -function getForwardsToUpdateMessage(action: ReportAction): string { +function getForwardsToUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const originalMessage = getOriginalMessage(action as ReportAction) as ForwardsToOriginalMessage | undefined; if (!originalMessage) { @@ -3175,32 +3023,28 @@ function getForwardsToUpdateMessage(action: ReportAction): string { const previousForwardsTo = originalMessage.previousForwardsTo ? formatPhoneNumber(originalMessage.previousForwardsTo.email) : undefined; if (!forwardsToEmail) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.removedForwardsTo', {approver: approvers, previousForwardsTo}); + return translate('workspaceActions.removedForwardsTo', {approver: approvers, previousForwardsTo}); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.changedForwardsTo', {approver: approvers, forwardsTo: forwardsToEmail, previousForwardsTo}); + return translate('workspaceActions.changedForwardsTo', {approver: approvers, forwardsTo: forwardsToEmail, previousForwardsTo}); } -function getWorkspaceReimbursementUpdateMessage(action: ReportAction): string { +function getWorkspaceReimbursementUpdateMessage(translate: LocalizedTranslate, action: ReportAction): string { const {enabled} = getOriginalMessage(action as ReportAction) ?? {}; if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REIMBURSEMENT_ENABLED && typeof enabled === 'boolean') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateReimbursementEnabled', {enabled}); + return translate('workspaceActions.updateReimbursementEnabled', {enabled}); } return getReportActionText(action); } -function getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(action: ReportAction): string { +function getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldMaxExpenseAmountNoReceipt, newMaxExpenseAmountNoReceipt, currency} = getOriginalMessage(action as ReportAction) ?? {}; if (typeof oldMaxExpenseAmountNoReceipt === 'number' && typeof newMaxExpenseAmountNoReceipt === 'number') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateMaxExpenseAmountNoReceipt', { + return translate('workspaceActions.updateMaxExpenseAmountNoReceipt', { oldValue: convertToDisplayString(oldMaxExpenseAmountNoReceipt, currency), newValue: convertToDisplayString(newMaxExpenseAmountNoReceipt, currency), }); @@ -3209,13 +3053,12 @@ function getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(action: ReportAction return getReportActionText(action); } -function getPolicyChangeLogMaxExpenseAmountMessage(action: ReportAction): string { +function getPolicyChangeLogMaxExpenseAmountMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldMaxExpenseAmount, newMaxExpenseAmount, currency} = getOriginalMessage(action as ReportAction) ?? {}; if (typeof oldMaxExpenseAmount === 'number' && typeof newMaxExpenseAmount === 'number') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateMaxExpenseAmount', { + return translate('workspaceActions.updateMaxExpenseAmount', { oldValue: convertToDisplayString(oldMaxExpenseAmount, currency), newValue: convertToDisplayString(newMaxExpenseAmount, currency), }); @@ -3224,12 +3067,11 @@ function getPolicyChangeLogMaxExpenseAmountMessage(action: ReportAction): string return getReportActionText(action); } -function getPolicyChangeLogDefaultBillableMessage(action: ReportAction): string { +function getPolicyChangeLogDefaultBillableMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldDefaultBillable, newDefaultBillable} = getOriginalMessage(action as ReportAction) ?? {}; if (typeof oldDefaultBillable === 'string' && typeof newDefaultBillable === 'string') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateDefaultBillable', { + return translate('workspaceActions.updateDefaultBillable', { oldValue: oldDefaultBillable, newValue: newDefaultBillable, }); @@ -3238,12 +3080,11 @@ function getPolicyChangeLogDefaultBillableMessage(action: ReportAction): string return getReportActionText(action); } -function getPolicyChangeLogDefaultReimbursableMessage(action: ReportAction): string { +function getPolicyChangeLogDefaultReimbursableMessage(translate: LocalizedTranslate, action: ReportAction): string { const {oldDefaultReimbursable, newDefaultReimbursable} = getOriginalMessage(action as ReportAction) ?? {}; if (typeof oldDefaultReimbursable === 'string' && typeof newDefaultReimbursable === 'string') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateDefaultReimbursable', { + return translate('workspaceActions.updateDefaultReimbursable', { oldValue: oldDefaultReimbursable, newValue: newDefaultReimbursable, }); @@ -3252,12 +3093,11 @@ function getPolicyChangeLogDefaultReimbursableMessage(action: ReportAction): str return getReportActionText(action); } -function getPolicyChangeLogDefaultTitleEnforcedMessage(action: ReportAction): string { +function getPolicyChangeLogDefaultTitleEnforcedMessage(translate: LocalizedTranslate, action: ReportAction): string { const {value} = getOriginalMessage(action as ReportAction) ?? {}; if (typeof value === 'boolean') { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateDefaultTitleEnforced', { + return translate('workspaceActions.updateDefaultTitleEnforced', { value, }); } @@ -3265,42 +3105,37 @@ function getPolicyChangeLogDefaultTitleEnforcedMessage(action: ReportAction): st return getReportActionText(action); } -function getPolicyChangeLogDeleteMemberMessage(reportAction: OnyxInputOrEntry): string { +function getPolicyChangeLogDeleteMemberMessage(translate: LocalizedTranslate, reportAction: OnyxInputOrEntry): string { if (!isPolicyChangeLogDeleteMemberMessage(reportAction)) { return ''; } const originalMessage = getOriginalMessage(reportAction); const email = formatPhoneNumber(originalMessage?.email ?? ''); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const role = translateLocal('workspace.common.roleName', {role: originalMessage?.role ?? ''}).toLowerCase(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.removeMember', email, role); + const role = translate('workspace.common.roleName', {role: originalMessage?.role ?? ''}).toLowerCase(); + return translate('report.actions.type.removeMember', email, role); } -function getAddedConnectionMessage(reportAction: OnyxEntry): string { +function getAddedConnectionMessage(translate: LocalizedTranslate, reportAction: OnyxEntry): string { if (!isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_INTEGRATION)) { return ''; } const originalMessage = getOriginalMessage(reportAction); const connectionName = originalMessage?.connectionName; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return connectionName ? translateLocal('report.actions.type.addedConnection', {connectionName}) : ''; + return connectionName ? translate('report.actions.type.addedConnection', {connectionName}) : ''; } -function getRemovedConnectionMessage(reportAction: OnyxEntry): string { +function getRemovedConnectionMessage(translate: LocalizedTranslate, reportAction: OnyxEntry): string { if (!isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { return ''; } const originalMessage = getOriginalMessage(reportAction); const connectionName = originalMessage?.connectionName; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return connectionName ? translateLocal('report.actions.type.removedConnection', {connectionName}) : ''; + return connectionName ? translate('report.actions.type.removedConnection', {connectionName}) : ''; } -function getRenamedAction(reportAction: OnyxEntry>, isExpenseReport: boolean, actorName?: string) { +function getRenamedAction(translate: LocalizedTranslate, reportAction: OnyxEntry>, isExpenseReport: boolean, actorName?: string) { const originalMessage = getOriginalMessage(reportAction); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('newRoomPage.renamedRoomAction', { + return translate('newRoomPage.renamedRoomAction', { actorName, isExpenseReport, oldName: originalMessage?.oldName ?? '', @@ -3308,47 +3143,42 @@ function getRenamedAction(reportAction: OnyxEntry) { +function getAddedApprovalRuleMessage(translate: LocalizedTranslate, reportAction: OnyxEntry) { const {name, approverAccountID, approverEmail, field, approverName} = getOriginalMessage(reportAction as ReportAction) ?? {}; if (name && approverAccountID && approverEmail && field && approverName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.addApprovalRule', approverEmail, approverName, field, name); + return translate('workspaceActions.addApprovalRule', approverEmail, approverName, field, name); } return getReportActionText(reportAction); } -function getDeletedApprovalRuleMessage(reportAction: OnyxEntry) { +function getDeletedApprovalRuleMessage(translate: LocalizedTranslate, reportAction: OnyxEntry) { const {name, approverAccountID, approverEmail, field, approverName} = getOriginalMessage(reportAction as ReportAction) ?? {}; if (name && approverAccountID && approverEmail && field && approverName) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.deleteApprovalRule', approverEmail, approverName, field, name); + return translate('workspaceActions.deleteApprovalRule', approverEmail, approverName, field, name); } return getReportActionText(reportAction); } -function getActionableCardFraudAlertResolutionMessage(reportAction: OnyxEntry) { +function getActionableCardFraudAlertResolutionMessage(translate: LocalizedTranslate, reportAction: OnyxEntry) { const {maskedCardNumber, resolution} = getOriginalMessage(reportAction as ReportAction) ?? {}; if (resolution === CONST.CARD_FRAUD_ALERT_RESOLUTION.RECOGNIZED) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('cardPage.cardFraudAlert.clearedMessage', {cardLastFour: maskedCardNumber?.slice(-4) ?? ''}); + return translate('cardPage.cardFraudAlert.clearedMessage', {cardLastFour: maskedCardNumber?.slice(-4) ?? ''}); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('cardPage.cardFraudAlert.deactivatedMessage', {cardLastFour: maskedCardNumber?.slice(-4) ?? ''}); + return translate('cardPage.cardFraudAlert.deactivatedMessage', {cardLastFour: maskedCardNumber?.slice(-4) ?? ''}); } -function getUpdatedApprovalRuleMessage(reportAction: OnyxEntry) { +function getUpdatedApprovalRuleMessage(translate: LocalizedTranslate, reportAction: OnyxEntry) { const {field, oldApproverEmail, oldApproverName, newApproverEmail, newApproverName, name} = getOriginalMessage(reportAction as ReportAction) ?? {}; if (field && oldApproverEmail && newApproverEmail && name) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updateApprovalRule', { + return translate('workspaceActions.updateApprovalRule', { field, name, newApproverEmail, @@ -3360,17 +3190,17 @@ function getUpdatedApprovalRuleMessage(reportAction: OnyxEntry) { return getReportActionText(reportAction); } -function getRemovedFromApprovalChainMessage(reportAction: OnyxEntry>) { +function getRemovedFromApprovalChainMessage(translate: LocalizedTranslate, reportAction: OnyxEntry>) { const originalMessage = getOriginalMessage(reportAction); const submittersNames = getPersonalDetailsByIDs({ accountIDs: originalMessage?.submittersAccountIDs ?? [], currentUserAccountID: currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID, }).map(({displayName, login}) => displayName ?? login ?? 'Unknown Submitter'); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.removedFromApprovalWorkflow', {submittersNames, count: submittersNames.length}); + return translate('workspaceActions.removedFromApprovalWorkflow', {submittersNames, count: submittersNames.length}); } function getActionableCardFraudAlertMessage( + translate: LocalizedTranslate, reportAction: OnyxEntry>, getLocalDateFromDatetime: LocaleContextProps['getLocalDateFromDatetime'], ) { @@ -3382,16 +3212,13 @@ function getActionableCardFraudAlertMessage( const formattedDate = reportAction?.created ? format(getLocalDateFromDatetime(reportAction?.created), 'MMM. d - h:mma').replaceAll(/am|pm/gi, (match) => match.toUpperCase()) : ''; if (resolution === CONST.CARD_FRAUD_ALERT_RESOLUTION.RECOGNIZED) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('cardPage.cardFraudAlert.clearedMessage', {cardLastFour}); + return translate('cardPage.cardFraudAlert.clearedMessage', {cardLastFour}); } if (resolution === CONST.CARD_FRAUD_ALERT_RESOLUTION.FRAUD) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('cardPage.cardFraudAlert.deactivatedMessage', {cardLastFour}); + return translate('cardPage.cardFraudAlert.deactivatedMessage', {cardLastFour}); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('cardPage.cardFraudAlert.alertMessage', { + return translate('cardPage.cardFraudAlert.alertMessage', { cardLastFour, amount: formattedAmount, merchant, @@ -3399,27 +3226,23 @@ function getActionableCardFraudAlertMessage( }); } -function getDemotedFromWorkspaceMessage(reportAction: OnyxEntry>) { +function getDemotedFromWorkspaceMessage(translate: LocalizedTranslate, reportAction: OnyxEntry>) { const originalMessage = getOriginalMessage(reportAction); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const policyName = originalMessage?.policyName ?? translateLocal('workspace.common.workspace'); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const oldRole = translateLocal('workspace.common.roleName', {role: originalMessage?.oldRole}).toLowerCase(); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.demotedFromWorkspace', {policyName, oldRole}); + const policyName = originalMessage?.policyName ?? translate('workspace.common.workspace'); + const oldRole = translate('workspace.common.roleName', {role: originalMessage?.oldRole}).toLowerCase(); + return translate('workspaceActions.demotedFromWorkspace', {policyName, oldRole}); } -function getUpdatedAuditRateMessage(reportAction: OnyxEntry) { +function getUpdatedAuditRateMessage(translate: LocalizedTranslate, reportAction: OnyxEntry) { const {oldAuditRate, newAuditRate} = getOriginalMessage(reportAction as ReportAction) ?? {}; if (typeof oldAuditRate !== 'number' || typeof newAuditRate !== 'number') { return getReportActionText(reportAction); } - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspaceActions.updatedAuditRate', {oldAuditRate, newAuditRate}); + return translate('workspaceActions.updatedAuditRate', {oldAuditRate, newAuditRate}); } -function getUpdatedManualApprovalThresholdMessage(reportAction: OnyxEntry) { +function getUpdatedManualApprovalThresholdMessage(translate: LocalizedTranslate, reportAction: OnyxEntry) { const { oldLimit, newLimit, @@ -3429,17 +3252,18 @@ function getUpdatedManualApprovalThresholdMessage(reportAction: OnyxEntry(reportAction: OnyxEntry) { +function getChangedApproverActionMessage( + translate: LocalizedTranslate, + reportAction: OnyxEntry, +) { const {mentionedAccountIDs} = getOriginalMessage(reportAction as ReportAction) ?? {}; // If mentionedAccountIDs exists and has values, use the first one if (mentionedAccountIDs?.length) { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('iou.changeApprover.changedApproverMessage', mentionedAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID); + return translate('iou.changeApprover.changedApproverMessage', mentionedAccountIDs.at(0) ?? CONST.DEFAULT_NUMBER_ID); } // Fallback: If mentionedAccountIDs is missing (common with OldDot take control actions), @@ -3448,8 +3272,7 @@ function getChangedApproverActionMessage) { +function getJoinRequestMessage(translate: LocalizedTranslate, reportAction: ReportAction) { // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 // eslint-disable-next-line @typescript-eslint/no-deprecated const policy = getPolicy(getOriginalMessage(reportAction)?.policyID); const userDetail = getPersonalDetailByEmail(getOriginalMessage(reportAction)?.email ?? ''); const userName = userDetail?.firstName ? `${userDetail.displayName} (${userDetail.login})` : (userDetail?.login ?? getOriginalMessage(reportAction)?.email); - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('workspace.inviteMessage.joinRequest', {user: userName ?? '', workspaceName: policy?.name ?? ''}); + return translate('workspace.inviteMessage.joinRequest', {user: userName ?? '', workspaceName: policy?.name ?? ''}); } function isCardActive(card?: Card): boolean { if (!card) { @@ -3565,7 +3387,7 @@ function getCardIssuedMessage({ } } -function getRoomChangeLogMessage(reportAction: ReportAction) { +function getRoomChangeLogMessage(translate: LocalizedTranslate, reportAction: ReportAction) { if (!isInviteOrRemovedAction(reportAction)) { return ''; } @@ -3573,12 +3395,9 @@ function getRoomChangeLogMessage(reportAction: ReportAction) { const targetAccountIDs: number[] = originalMessage?.targetAccountIDs ?? []; const actionText = isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM) || isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM) - ? // eslint-disable-next-line @typescript-eslint/no-deprecated - translateLocal('workspace.invite.invited') - : // eslint-disable-next-line @typescript-eslint/no-deprecated - translateLocal('workspace.invite.removed'); - // eslint-disable-next-line @typescript-eslint/no-deprecated - const userText = (targetAccountIDs.length === 1 ? translateLocal('common.member') : translateLocal('common.members')).toLowerCase(); + ? translate('workspace.invite.invited') + : translate('workspace.invite.removed'); + const userText = (targetAccountIDs.length === 1 ? translate('common.member') : translate('common.members')).toLowerCase(); return `${actionText} ${targetAccountIDs.length} ${userText}`; } @@ -3629,13 +3448,12 @@ function wasMessageReceivedWhileOffline( return !wasByCurrentUser && wasCreatedOffline && !(action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD || action.isOptimisticAction); } -function getIntegrationSyncFailedMessage(action: OnyxEntry, policyID?: string, shouldShowOldDotLink = false): string { +function getIntegrationSyncFailedMessage(translate: LocalizedTranslate, action: OnyxEntry, policyID?: string, shouldShowOldDotLink = false): string { const {label, errorMessage} = getOriginalMessage(action as ReportAction) ?? {label: '', errorMessage: ''}; const param = encodeURIComponent(`{"policyID": "${policyID}"}`); const workspaceAccountingLink = shouldShowOldDotLink ? `${oldDotEnvironmentURL}/policy?param=${param}#connections` : `${environmentURL}/${ROUTES.POLICY_ACCOUNTING.getRoute(policyID)}`; - // eslint-disable-next-line @typescript-eslint/no-deprecated - return translateLocal('report.actions.type.integrationSyncFailed', { + return translate('report.actions.type.integrationSyncFailed', { label, errorMessage, workspaceAccountingLink, @@ -3851,9 +3669,6 @@ export { getWorkspaceCustomUnitUpdatedMessage, getRoomChangeLogMessage, shouldShowActivateCard, - getReopenedMessage, - getLeaveRoomMessage, - getRetractedMessage, isReopenedAction, isRetractedAction, getIntegrationSyncFailedMessage, @@ -3861,7 +3676,6 @@ export { getManagerOnVacation, getVacationer, getSubmittedTo, - getReceiptScanFailedMessage, getChangedApproverActionMessage, getDelegateAccountIDFromReportAction, isPendingHide, diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts index 1436f5972e32..2021116a18ea 100644 --- a/src/libs/ReportNameUtils.ts +++ b/src/libs/ReportNameUtils.ts @@ -43,10 +43,8 @@ import { getPolicyChangeLogDefaultTitleEnforcedMessage, getPolicyChangeLogMaxExpenseAmountNoReceiptMessage, getRenamedAction, - getReopenedMessage, getReportActionMessage as getReportActionMessageFromActionsUtils, getReportActionText, - getRetractedMessage, getTravelUpdateMessage, getWorkspaceCurrencyUpdateMessage, getWorkspaceCustomUnitRateAddedMessage, @@ -383,10 +381,12 @@ function computeReportNameBasedOnReportAction(parentReportAction?: ReportAction, return getRejectedReportMessage(); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RETRACTED) { - return getRetractedMessage(); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return translateLocal('iou.retracted'); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REOPENED) { - return getReopenedMessage(); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return translateLocal('iou.reopened'); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { return getUpgradeWorkspaceMessage(); @@ -395,10 +395,12 @@ function computeReportNameBasedOnReportAction(parentReportAction?: ReportAction, return getDowngradeWorkspaceMessage(); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - return getWorkspaceCurrencyUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceCurrencyUpdateMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - return getWorkspaceUpdateFieldMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceUpdateFieldMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) { // eslint-disable-next-line @typescript-eslint/no-deprecated @@ -408,16 +410,20 @@ function computeReportNameBasedOnReportAction(parentReportAction?: ReportAction, return Str.htmlDecode(getWorkspaceNameUpdatedMessage(parentReportAction)); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - return getWorkspaceFrequencyUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceFrequencyUpdateMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { - return getWorkspaceReportFieldAddMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceReportFieldAddMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) { - return getWorkspaceReportFieldUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceReportFieldUpdateMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) { - return getWorkspaceReportFieldDeleteMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceReportFieldDeleteMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION)) { @@ -425,21 +431,26 @@ function computeReportNameBasedOnReportAction(parentReportAction?: ReportAction, } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { - return getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE)) { - return getPolicyChangeLogDefaultBillableMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getPolicyChangeLogDefaultBillableMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_REIMBURSABLE)) { - return getPolicyChangeLogDefaultReimbursableMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getPolicyChangeLogDefaultReimbursableMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED)) { - return getPolicyChangeLogDefaultTitleEnforcedMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getPolicyChangeLogDefaultTitleEnforcedMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT) && getOriginalMessage(parentReportAction)?.resolution) { - return getActionableCardFraudAlertResolutionMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getActionableCardFraudAlertResolutionMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) { @@ -452,11 +463,13 @@ function computeReportNameBasedOnReportAction(parentReportAction?: ReportAction, } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) { - return getChangedApproverActionMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getChangedApproverActionMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName && isTagModificationAction(parentReportAction?.actionName)) { - return getCleanedTagName(getWorkspaceTagUpdateMessage(parentReportAction) ?? ''); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getCleanedTagName(getWorkspaceTagUpdateMessage(translateLocal, parentReportAction) ?? ''); } if (isMovedAction(parentReportAction)) { @@ -507,7 +520,8 @@ function computeReportNameBasedOnReportAction(parentReportAction?: ReportAction, } if (isActionableJoinRequest(parentReportAction)) { - return getJoinRequestMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getJoinRequestMessage(translateLocal, parentReportAction); } if (isTaskReport(report) && isCanceledTaskReport(report, parentReportAction)) { @@ -516,21 +530,26 @@ function computeReportNameBasedOnReportAction(parentReportAction?: ReportAction, } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { - return getIntegrationSyncFailedMessage(parentReportAction, report?.policyID); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getIntegrationSyncFailedMessage(translateLocal, parentReportAction, report?.policyID); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) { - return getTravelUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getTravelUpdateMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE)) { - return getWorkspaceCustomUnitRateAddedMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceCustomUnitRateAddedMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT_RATE)) { - return getWorkspaceCustomUnitRateUpdatedMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceCustomUnitRateUpdatedMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE)) { - return getWorkspaceCustomUnitRateDeletedMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceCustomUnitRateDeletedMessage(translateLocal, parentReportAction); } return undefined; @@ -557,12 +576,14 @@ function computeChatThreadReportName(report: Report, reportNameValuePairs: Repor } if (!isEmptyObject(parentReportAction) && isOldDotReportAction(parentReportAction)) { - return getMessageOfOldDotReportAction(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getMessageOfOldDotReportAction(translateLocal, parentReportAction); } if (isRenamedAction(parentReportAction)) { const parent = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`]; - return getRenamedAction(parentReportAction, isExpenseReport(parent)); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getRenamedAction(translateLocal, parentReportAction, isExpenseReport(parent)); } if (parentReportActionMessage?.isDeletedParentAction) { diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b4a62cf5f02c..952905aa1ddc 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -197,14 +197,12 @@ import { getPolicyChangeLogDefaultTitleEnforcedMessage, getPolicyChangeLogMaxExpenseAmountNoReceiptMessage, getRenamedAction, - getReopenedMessage, getReportAction, getReportActionActorAccountID, getReportActionHtml, getReportActionMessage as getReportActionMessageReportUtils, getReportActionMessageText, getReportActionText, - getRetractedMessage, getSortedReportActions, getSubmitsToUpdateMessage, getTravelUpdateMessage, @@ -5503,7 +5501,8 @@ function getReportActionMessage({ } if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) { - return getExportIntegrationLastMessageText(reportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getExportIntegrationLastMessageText(translateLocal, reportAction); } if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { @@ -5610,10 +5609,12 @@ function getReportName( return getRejectedReportMessage(); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RETRACTED) { - return getRetractedMessage(); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return translateLocal('iou.retracted'); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REOPENED) { - return getReopenedMessage(); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return translateLocal('iou.reopened'); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE) { return getUpgradeWorkspaceMessage(); @@ -5625,13 +5626,16 @@ function getReportName( return getForcedCorporateUpgradeMessage(); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - return getWorkspaceCurrencyUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceCurrencyUpdateMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - return getWorkspaceUpdateFieldMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceUpdateFieldMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FEATURE_ENABLED) { - return getWorkspaceFeatureEnabledMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceFeatureEnabledMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) { // eslint-disable-next-line @typescript-eslint/no-deprecated @@ -5641,16 +5645,20 @@ function getReportName( return Str.htmlDecode(getWorkspaceNameUpdatedMessage(parentReportAction)); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - return getWorkspaceFrequencyUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceFrequencyUpdateMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { - return getWorkspaceReportFieldAddMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceReportFieldAddMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) { - return getWorkspaceReportFieldUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceReportFieldUpdateMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) { - return getWorkspaceReportFieldDeleteMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceReportFieldDeleteMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION)) { @@ -5662,36 +5670,46 @@ function getReportName( } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { - return getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REIMBURSEMENT_ENABLED)) { - return getWorkspaceReimbursementUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceReimbursementUpdateMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE)) { - return getPolicyChangeLogDefaultBillableMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getPolicyChangeLogDefaultBillableMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_REIMBURSABLE)) { - return getPolicyChangeLogDefaultReimbursableMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getPolicyChangeLogDefaultReimbursableMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED)) { - return getPolicyChangeLogDefaultTitleEnforcedMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getPolicyChangeLogDefaultTitleEnforcedMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_IS_ATTENDEE_TRACKING_ENABLED)) { - return getWorkspaceAttendeeTrackingUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceAttendeeTrackingUpdateMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_APPROVER)) { - return getDefaultApproverUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getDefaultApproverUpdateMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_SUBMITS_TO)) { - return getSubmitsToUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getSubmitsToUpdateMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FORWARDS_TO)) { - return getForwardsToUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getForwardsToUpdateMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT) && getOriginalMessage(parentReportAction)?.resolution) { - return getActionableCardFraudAlertResolutionMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getActionableCardFraudAlertResolutionMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) { @@ -5704,11 +5722,13 @@ function getReportName( } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) { - return getChangedApproverActionMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getChangedApproverActionMessage(translateLocal, parentReportAction); } if (parentReportAction?.actionName && isTagModificationAction(parentReportAction?.actionName)) { - return getCleanedTagName(getWorkspaceTagUpdateMessage(parentReportAction) ?? ''); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getCleanedTagName(getWorkspaceTagUpdateMessage(translateLocal, parentReportAction) ?? ''); } if (isMovedAction(parentReportAction)) { @@ -5720,11 +5740,13 @@ function getReportName( isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAX) || isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAX) ) { - return getWorkspaceTaxUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceTaxUpdateMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { - return getDismissedViolationMessageText(getOriginalMessage(parentReportAction)); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getDismissedViolationMessageText(translateLocal, getOriginalMessage(parentReportAction)); } if (isMoneyRequestAction(parentReportAction)) { @@ -5771,7 +5793,8 @@ function getReportName( } if (isActionableJoinRequest(parentReportAction)) { - return getJoinRequestMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getJoinRequestMessage(translateLocal, parentReportAction); } if (isTaskReport(report) && isCanceledTaskReport(report, parentReportAction)) { @@ -5784,21 +5807,26 @@ function getReportName( } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { - return getIntegrationSyncFailedMessage(parentReportAction, report?.policyID); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getIntegrationSyncFailedMessage(translateLocal, parentReportAction, report?.policyID); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) { - return getTravelUpdateMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getTravelUpdateMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE)) { - return getWorkspaceCustomUnitRateAddedMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceCustomUnitRateAddedMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT_RATE)) { - return getWorkspaceCustomUnitRateUpdatedMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceCustomUnitRateUpdatedMessage(translateLocal, parentReportAction); } if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE)) { - return getWorkspaceCustomUnitRateDeletedMessage(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getWorkspaceCustomUnitRateDeletedMessage(translateLocal, parentReportAction); } if (isChatThread(report)) { @@ -5812,11 +5840,13 @@ function getReportName( } if (!isEmptyObject(parentReportAction) && isOldDotReportAction(parentReportAction)) { - return getMessageOfOldDotReportAction(parentReportAction); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getMessageOfOldDotReportAction(translateLocal, parentReportAction); } if (isRenamedAction(parentReportAction)) { - return getRenamedAction(parentReportAction, isExpenseReport(getReport(report.parentReportID, allReports))); + // eslint-disable-next-line @typescript-eslint/no-deprecated + return getRenamedAction(translateLocal, parentReportAction, isExpenseReport(getReport(report.parentReportID, allReports))); } if (parentReportActionMessage?.isDeletedParentAction) { @@ -8254,7 +8284,8 @@ function buildOptimisticDismissedViolationReportAction( { type: CONST.REPORT.MESSAGE.TYPE.TEXT, style: 'normal', - text: getDismissedViolationMessageText(originalMessage), + // eslint-disable-next-line @typescript-eslint/no-deprecated + text: getDismissedViolationMessageText(translateLocal, originalMessage), }, ], originalMessage, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 694842b3ad35..01fa1ab26459 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -53,11 +53,9 @@ import { getPolicyChangeLogUpdateEmployee, getRemovedConnectionMessage, getRenamedAction, - getReopenedMessage, getReportAction, getReportActionActorAccountID, getReportActionMessageText, - getRetractedMessage, getRoomAvatarUpdatedMessage, getSubmitsToUpdateMessage, getTagListNameUpdatedMessage, @@ -809,7 +807,7 @@ function getOptionData({ const prefix = getReportSubtitlePrefix(report); if (isRenamedAction(lastAction)) { - result.alternateText = getRenamedAction(lastAction, isExpense, lastActorDisplayName); + result.alternateText = getRenamedAction(translate, lastAction, isExpense, lastActorDisplayName); } else if (isTaskAction(lastAction)) { result.alternateText = formatReportLastMessageText(getTaskReportActionMessage(lastAction).text); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_ROOM) { @@ -849,13 +847,13 @@ function getOptionData({ } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME)) { result.alternateText = getWorkspaceNameUpdatedMessage(lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT) && getOriginalMessage(lastAction)?.resolution) { - result.alternateText = getActionableCardFraudAlertResolutionMessage(lastAction); + result.alternateText = getActionableCardFraudAlertResolutionMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION)) { - result.alternateText = getWorkspaceDescriptionUpdatedMessage(lastAction); + result.alternateText = getWorkspaceDescriptionUpdatedMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY)) { - result.alternateText = getWorkspaceCurrencyUpdateMessage(lastAction); + result.alternateText = getWorkspaceCurrencyUpdateMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY)) { - result.alternateText = getWorkspaceFrequencyUpdateMessage(lastAction); + result.alternateText = getWorkspaceFrequencyUpdateMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_UPGRADE)) { result.alternateText = translate('workspaceActions.upgradedWorkspace'); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.CORPORATE_FORCE_UPGRADE)) { @@ -863,113 +861,113 @@ function getOptionData({ } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.TEAM_DOWNGRADE)) { result.alternateText = translate('workspaceActions.downgradedWorkspace'); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { - result.alternateText = Parser.htmlToText(getIntegrationSyncFailedMessage(lastAction, report?.policyID)); + result.alternateText = Parser.htmlToText(getIntegrationSyncFailedMessage(translate, lastAction, report?.policyID)); } else if ( isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY) || isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY) || isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY) || isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME) ) { - result.alternateText = getWorkspaceCategoryUpdateMessage(lastAction); + result.alternateText = getWorkspaceCategoryUpdateMessage(translate, lastAction); } else if ( isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAX) || isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAX) || isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAX) ) { - result.alternateText = getWorkspaceTaxUpdateMessage(lastAction); + result.alternateText = getWorkspaceTaxUpdateMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_TAX_NAME)) { - result.alternateText = getCustomTaxNameUpdateMessage(lastAction); + result.alternateText = getCustomTaxNameUpdateMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY_DEFAULT_TAX)) { - result.alternateText = getCurrencyDefaultTaxUpdateMessage(lastAction); + result.alternateText = getCurrencyDefaultTaxUpdateMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FOREIGN_CURRENCY_DEFAULT_TAX)) { - result.alternateText = getForeignCurrencyDefaultTaxUpdateMessage(lastAction); + result.alternateText = getForeignCurrencyDefaultTaxUpdateMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_LIST_NAME)) { - result.alternateText = getCleanedTagName(getTagListNameUpdatedMessage(lastAction) ?? ''); + result.alternateText = getCleanedTagName(getTagListNameUpdatedMessage(translate, lastAction) ?? ''); } else if (isTagModificationAction(lastAction?.actionName ?? '')) { - result.alternateText = getCleanedTagName(getWorkspaceTagUpdateMessage(lastAction) ?? ''); + result.alternateText = getCleanedTagName(getWorkspaceTagUpdateMessage(translate, lastAction) ?? ''); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT)) { - result.alternateText = getWorkspaceCustomUnitUpdatedMessage(lastAction); + result.alternateText = getWorkspaceCustomUnitUpdatedMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE)) { - result.alternateText = getWorkspaceCustomUnitRateAddedMessage(lastAction); + result.alternateText = getWorkspaceCustomUnitRateAddedMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT_RATE)) { - result.alternateText = getWorkspaceCustomUnitRateUpdatedMessage(lastAction); + result.alternateText = getWorkspaceCustomUnitRateUpdatedMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE)) { - result.alternateText = getWorkspaceCustomUnitRateDeletedMessage(lastAction); + result.alternateText = getWorkspaceCustomUnitRateDeletedMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD)) { - result.alternateText = getWorkspaceReportFieldAddMessage(lastAction); + result.alternateText = getWorkspaceReportFieldAddMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD)) { - result.alternateText = getWorkspaceReportFieldUpdateMessage(lastAction); + result.alternateText = getWorkspaceReportFieldUpdateMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD)) { - result.alternateText = getWorkspaceReportFieldDeleteMessage(lastAction); + result.alternateText = getWorkspaceReportFieldDeleteMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - result.alternateText = getWorkspaceUpdateFieldMessage(lastAction); + result.alternateText = getWorkspaceUpdateFieldMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FEATURE_ENABLED) { - result.alternateText = getWorkspaceFeatureEnabledMessage(lastAction); + result.alternateText = getWorkspaceFeatureEnabledMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_IS_ATTENDEE_TRACKING_ENABLED) { - result.alternateText = getWorkspaceAttendeeTrackingUpdateMessage(lastAction); + result.alternateText = getWorkspaceAttendeeTrackingUpdateMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_APPROVER) { - result.alternateText = getDefaultApproverUpdateMessage(lastAction); + result.alternateText = getDefaultApproverUpdateMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_SUBMITS_TO) { - result.alternateText = getSubmitsToUpdateMessage(lastAction); + result.alternateText = getSubmitsToUpdateMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FORWARDS_TO) { - result.alternateText = getForwardsToUpdateMessage(lastAction); + result.alternateText = getForwardsToUpdateMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REIMBURSEMENT_ENABLED) { - result.alternateText = getWorkspaceReimbursementUpdateMessage(lastAction); + result.alternateText = getWorkspaceReimbursementUpdateMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { - result.alternateText = getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(lastAction); + result.alternateText = getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { - result.alternateText = getPolicyChangeLogMaxExpenseAmountMessage(lastAction); + result.alternateText = getPolicyChangeLogMaxExpenseAmountMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE) { - result.alternateText = getPolicyChangeLogDefaultBillableMessage(lastAction); + result.alternateText = getPolicyChangeLogDefaultBillableMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_REIMBURSABLE) { - result.alternateText = getPolicyChangeLogDefaultReimbursableMessage(lastAction); + result.alternateText = getPolicyChangeLogDefaultReimbursableMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED) { - result.alternateText = getPolicyChangeLogDefaultTitleEnforcedMessage(lastAction); + result.alternateText = getPolicyChangeLogDefaultTitleEnforcedMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) { - result.alternateText = getPolicyChangeLogEmployeeLeftMessage(lastAction, true); + result.alternateText = getPolicyChangeLogEmployeeLeftMessage(translate, lastAction, true); } else if (isCardIssuedAction(lastAction)) { result.alternateText = getCardIssuedMessage({reportAction: lastAction, expensifyCard: card, translate}); } else if (lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && lastActorDisplayName && lastMessageTextFromReport) { const displayName = (lastMessageTextFromReport.length > 0 && getLastActorDisplayNameFromLastVisibleActions(report, lastActorDetails)) || lastActorDisplayName; result.alternateText = formatReportLastMessageText(`${displayName}: ${lastMessageText}`); } else if (lastAction && isOldDotReportAction(lastAction)) { - result.alternateText = getMessageOfOldDotReportAction(lastAction); + result.alternateText = getMessageOfOldDotReportAction(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) { - result.alternateText = Parser.htmlToText(getUpdateRoomDescriptionMessage(lastAction)); + result.alternateText = Parser.htmlToText(getUpdateRoomDescriptionMessage(translate, lastAction)); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_AVATAR) { - result.alternateText = getRoomAvatarUpdatedMessage(lastAction); + result.alternateText = getRoomAvatarUpdatedMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { - result.alternateText = getPolicyChangeLogAddEmployeeMessage(lastAction); + result.alternateText = getPolicyChangeLogAddEmployeeMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { - result.alternateText = getPolicyChangeLogUpdateEmployee(lastAction); + result.alternateText = getPolicyChangeLogUpdateEmployee(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { - result.alternateText = getPolicyChangeLogDeleteMemberMessage(lastAction); + result.alternateText = getPolicyChangeLogDeleteMemberMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION)) { result.alternateText = Parser.htmlToText(getUnreportedTransactionMessage(lastAction)); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { result.alternateText = getReportActionMessageText(lastAction) ?? ''; } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_INTEGRATION) { - result.alternateText = getAddedConnectionMessage(lastAction); + result.alternateText = getAddedConnectionMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION) { - result.alternateText = getRemovedConnectionMessage(lastAction); + result.alternateText = getRemovedConnectionMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUDIT_RATE) { - result.alternateText = getUpdatedAuditRateMessage(lastAction); + result.alternateText = getUpdatedAuditRateMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_APPROVER_RULE) { - result.alternateText = getAddedApprovalRuleMessage(lastAction); + result.alternateText = getAddedApprovalRuleMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_APPROVER_RULE) { - result.alternateText = getDeletedApprovalRuleMessage(lastAction); + result.alternateText = getDeletedApprovalRuleMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_APPROVER_RULE) { - result.alternateText = getUpdatedApprovalRuleMessage(lastAction); + result.alternateText = getUpdatedApprovalRuleMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD) { - result.alternateText = getUpdatedManualApprovalThresholdMessage(lastAction); + result.alternateText = getUpdatedManualApprovalThresholdMessage(translate, lastAction); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RETRACTED) { - result.alternateText = getRetractedMessage(); + result.alternateText = translate('iou.retracted'); } else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REOPENED) { - result.alternateText = getReopenedMessage(); + result.alternateText = translate('iou.reopened'); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) { - result.alternateText = getTravelUpdateMessage(lastAction); + result.alternateText = getTravelUpdateMessage(translate, lastAction); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) { - result.alternateText = Parser.htmlToText(getChangedApproverActionMessage(lastAction)); + result.alternateText = Parser.htmlToText(getChangedApproverActionMessage(translate, lastAction)); } else if (isActionOfType(lastAction, CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION)) { result.alternateText = Parser.htmlToText(getMovedTransactionMessage(lastAction)); } else { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 69365389c1ab..571301c99bce 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -32,6 +32,7 @@ import { getChangedApproverActionMessage, getDefaultApproverUpdateMessage, getDeletedApprovalRuleMessage, + getDismissedViolationMessageText, getDynamicExternalWorkflowRoutedMessage, getExportIntegrationMessageHTML, getForwardsToUpdateMessage, @@ -52,7 +53,6 @@ import { getPolicyChangeLogUpdateEmployee, getRemovedConnectionMessage, getRenamedAction, - getReopenedMessage, getReportAction, getReportActionMessageText, getRoomAvatarUpdatedMessage, @@ -687,71 +687,71 @@ const ContextMenuActions: ContextMenuAction[] = [ Clipboard.setString(taskPreviewMessage); } else if (isMemberChangeAction(reportAction)) { // eslint-disable-next-line @typescript-eslint/no-deprecated - const logMessage = getMemberChangeMessageFragment(reportAction, getReportNameDeprecated).html ?? ''; + const logMessage = getMemberChangeMessageFragment(translate, reportAction, getReportNameDeprecated).html ?? ''; setClipboardMessage(logMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { Clipboard.setString(Str.htmlDecode(getWorkspaceNameUpdatedMessage(reportAction))); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DESCRIPTION) { - Clipboard.setString(getWorkspaceDescriptionUpdatedMessage(reportAction)); + Clipboard.setString(getWorkspaceDescriptionUpdatedMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - Clipboard.setString(getWorkspaceCurrencyUpdateMessage(reportAction)); + Clipboard.setString(getWorkspaceCurrencyUpdateMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - Clipboard.setString(getWorkspaceFrequencyUpdateMessage(reportAction)); + Clipboard.setString(getWorkspaceFrequencyUpdateMessage(translate, reportAction)); } else if ( reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { - Clipboard.setString(getWorkspaceCategoryUpdateMessage(reportAction)); + Clipboard.setString(getWorkspaceCategoryUpdateMessage(translate, reportAction)); } else if ( reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAX || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAX || reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAX ) { - Clipboard.setString(getWorkspaceTaxUpdateMessage(reportAction)); + Clipboard.setString(getWorkspaceTaxUpdateMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_LIST_NAME) { - Clipboard.setString(getCleanedTagName(getTagListNameUpdatedMessage(reportAction))); + Clipboard.setString(getCleanedTagName(getTagListNameUpdatedMessage(translate, reportAction))); } else if (isTagModificationAction(reportAction.actionName)) { - Clipboard.setString(getCleanedTagName(getWorkspaceTagUpdateMessage(reportAction))); + Clipboard.setString(getCleanedTagName(getWorkspaceTagUpdateMessage(translate, reportAction))); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT) { - Clipboard.setString(getWorkspaceCustomUnitUpdatedMessage(reportAction)); + Clipboard.setString(getWorkspaceCustomUnitUpdatedMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { - Clipboard.setString(getWorkspaceCustomUnitRateAddedMessage(reportAction)); + Clipboard.setString(getWorkspaceCustomUnitRateAddedMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT_RATE) { - Clipboard.setString(getWorkspaceCustomUnitRateUpdatedMessage(reportAction)); + Clipboard.setString(getWorkspaceCustomUnitRateUpdatedMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { - Clipboard.setString(getWorkspaceCustomUnitRateDeletedMessage(reportAction)); + Clipboard.setString(getWorkspaceCustomUnitRateDeletedMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { - Clipboard.setString(getWorkspaceReportFieldAddMessage(reportAction)); + Clipboard.setString(getWorkspaceReportFieldAddMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) { - Clipboard.setString(getWorkspaceReportFieldUpdateMessage(reportAction)); + Clipboard.setString(getWorkspaceReportFieldUpdateMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) { - Clipboard.setString(getWorkspaceReportFieldDeleteMessage(reportAction)); + Clipboard.setString(getWorkspaceReportFieldDeleteMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD) { - setClipboardMessage(getWorkspaceUpdateFieldMessage(reportAction)); + setClipboardMessage(getWorkspaceUpdateFieldMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FEATURE_ENABLED) { - Clipboard.setString(getWorkspaceFeatureEnabledMessage(reportAction)); + Clipboard.setString(getWorkspaceFeatureEnabledMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_IS_ATTENDEE_TRACKING_ENABLED) { - Clipboard.setString(getWorkspaceAttendeeTrackingUpdateMessage(reportAction)); + Clipboard.setString(getWorkspaceAttendeeTrackingUpdateMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_APPROVER) { - Clipboard.setString(getDefaultApproverUpdateMessage(reportAction)); + Clipboard.setString(getDefaultApproverUpdateMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_SUBMITS_TO) { - Clipboard.setString(getSubmitsToUpdateMessage(reportAction)); + Clipboard.setString(getSubmitsToUpdateMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FORWARDS_TO) { - Clipboard.setString(getForwardsToUpdateMessage(reportAction)); + Clipboard.setString(getForwardsToUpdateMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REIMBURSEMENT_ENABLED) { - Clipboard.setString(getWorkspaceReimbursementUpdateMessage(reportAction)); + Clipboard.setString(getWorkspaceReimbursementUpdateMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT) { - Clipboard.setString(getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(reportAction)); + Clipboard.setString(getPolicyChangeLogMaxExpenseAmountNoReceiptMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT) { - Clipboard.setString(getPolicyChangeLogMaxExpenseAmountMessage(reportAction)); + Clipboard.setString(getPolicyChangeLogMaxExpenseAmountMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE) { - Clipboard.setString(getPolicyChangeLogDefaultBillableMessage(reportAction)); + Clipboard.setString(getPolicyChangeLogDefaultBillableMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_REIMBURSABLE) { - Clipboard.setString(getPolicyChangeLogDefaultReimbursableMessage(reportAction)); + Clipboard.setString(getPolicyChangeLogDefaultReimbursableMessage(translate, reportAction)); } else if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED) { - Clipboard.setString(getPolicyChangeLogDefaultTitleEnforcedMessage(reportAction)); + Clipboard.setString(getPolicyChangeLogDefaultTitleEnforcedMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION)) { setClipboardMessage(getUnreportedTransactionMessage(reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) { @@ -761,12 +761,12 @@ const ContextMenuActions: ContextMenuAction[] = [ getReimbursementQueuedActionMessage({reportAction, formatPhoneNumber: formatPhoneNumberPhoneUtils, reportOrID: reportID, shouldUseShortDisplayName: false}), ); } else if (isActionableMentionWhisper(reportAction)) { - const mentionWhisperMessage = getActionableMentionWhisperMessage(reportAction); + const mentionWhisperMessage = getActionableMentionWhisperMessage(translate, reportAction); setClipboardMessage(mentionWhisperMessage); } else if (isActionableTrackExpense(reportAction)) { setClipboardMessage(CONST.ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE); } else if (isRenamedAction(reportAction)) { - setClipboardMessage(getRenamedAction(reportAction, isExpenseReport(report))); + setClipboardMessage(getRenamedAction(translate, reportAction, isExpenseReport(report))); } else if ( isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED) || @@ -817,64 +817,62 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RETRACTED) { Clipboard.setString(translate('iou.retracted')); } else if (isOldDotReportAction(reportAction)) { - const oldDotActionMessage = getMessageOfOldDotReportAction(reportAction); + const oldDotActionMessage = getMessageOfOldDotReportAction(translate, reportAction); Clipboard.setString(oldDotActionMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION) { const originalMessage = getOriginalMessage(reportAction) as ReportAction['originalMessage']; - const reason = originalMessage?.reason; - const violationName = originalMessage?.violationName; - Clipboard.setString(translate(`violationDismissal.${violationName}.${reason}` as TranslationPaths)); + Clipboard.setString(getDismissedViolationMessageText(translate, originalMessage)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.RESOLVED_DUPLICATES) { Clipboard.setString(translate('violations.resolvedDuplicates')); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION) { - setClipboardMessage(getExportIntegrationMessageHTML(reportAction)); + setClipboardMessage(getExportIntegrationMessageHTML(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) { - setClipboardMessage(getUpdateRoomDescriptionMessage(reportAction)); + setClipboardMessage(getUpdateRoomDescriptionMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_AVATAR) { - setClipboardMessage(getRoomAvatarUpdatedMessage(reportAction)); + setClipboardMessage(getRoomAvatarUpdatedMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { - setClipboardMessage(getPolicyChangeLogAddEmployeeMessage(reportAction)); + setClipboardMessage(getPolicyChangeLogAddEmployeeMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { - setClipboardMessage(getPolicyChangeLogUpdateEmployee(reportAction)); + setClipboardMessage(getPolicyChangeLogUpdateEmployee(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { - setClipboardMessage(getPolicyChangeLogDeleteMemberMessage(reportAction)); + setClipboardMessage(getPolicyChangeLogDeleteMemberMessage(translate, reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) { setClipboardMessage(getDeletedTransactionMessage(reportAction)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.REOPENED) { - setClipboardMessage(getReopenedMessage()); + setClipboardMessage(translate('iou.reopened')); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { - setClipboardMessage(getIntegrationSyncFailedMessage(reportAction, report?.policyID, isTryNewDotNVPDismissed)); + setClipboardMessage(getIntegrationSyncFailedMessage(translate, reportAction, report?.policyID, isTryNewDotNVPDismissed)); } else if (isCardIssuedAction(reportAction)) { setClipboardMessage(getCardIssuedMessage({reportAction, shouldRenderHTML: true, policyID: report?.policyID, expensifyCard: card, translate})); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_INTEGRATION)) { - setClipboardMessage(getAddedConnectionMessage(reportAction)); + setClipboardMessage(getAddedConnectionMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { - setClipboardMessage(getRemovedConnectionMessage(reportAction)); + setClipboardMessage(getRemovedConnectionMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) { - setClipboardMessage(getTravelUpdateMessage(reportAction)); + setClipboardMessage(getTravelUpdateMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUDIT_RATE)) { - setClipboardMessage(getUpdatedAuditRateMessage(reportAction)); + setClipboardMessage(getUpdatedAuditRateMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_APPROVER_RULE)) { - setClipboardMessage(getAddedApprovalRuleMessage(reportAction)); + setClipboardMessage(getAddedApprovalRuleMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_APPROVER_RULE)) { - setClipboardMessage(getDeletedApprovalRuleMessage(reportAction)); + setClipboardMessage(getDeletedApprovalRuleMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_APPROVER_RULE)) { - setClipboardMessage(getUpdatedApprovalRuleMessage(reportAction)); + setClipboardMessage(getUpdatedApprovalRuleMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD)) { - setClipboardMessage(getUpdatedManualApprovalThresholdMessage(reportAction)); + setClipboardMessage(getUpdatedManualApprovalThresholdMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.TAKE_CONTROL) || isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REROUTE)) { - setClipboardMessage(getChangedApproverActionMessage(reportAction)); + setClipboardMessage(getChangedApproverActionMessage(translate, reportAction)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION)) { setClipboardMessage(getMovedTransactionMessage(reportAction)); } else if (isMovedAction(reportAction)) { setClipboardMessage(getMovedActionMessage(reportAction, originalReport)); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT)) { - setClipboardMessage(getActionableCardFraudAlertMessage(reportAction, getLocalDateFromDatetime)); + setClipboardMessage(getActionableCardFraudAlertMessage(translate, reportAction, getLocalDateFromDatetime)); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY) { const displayMessage = getPolicyChangeMessage(reportAction); Clipboard.setString(displayMessage); } else if (isActionableJoinRequest(reportAction)) { - const displayMessage = getJoinRequestMessage(reportAction); + const displayMessage = getJoinRequestMessage(translate, reportAction); Clipboard.setString(displayMessage); } else if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.DYNAMIC_EXTERNAL_WORKFLOW_ROUTED)) { setClipboardMessage(getDynamicExternalWorkflowRoutedMessage(reportAction, translate)); diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 9a258ba7eb10..21b82c11f32f 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -92,7 +92,6 @@ import { getRemovedConnectionMessage, getRemovedFromApprovalChainMessage, getRenamedAction, - getReopenedMessage, getReportActionMessage, getReportActionText, getSubmitsToUpdateMessage, @@ -1308,7 +1307,7 @@ function PureReportActionItem({ } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.RETRACTED) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REOPENED) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CHANGE_POLICY) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.DELETED_TRANSACTION) { @@ -1345,7 +1344,7 @@ function PureReportActionItem({ } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.TRAVEL_UPDATE)) { children = ( - ${getTravelUpdateMessage(action, formatTravelDate)}`} /> + ${getTravelUpdateMessage(translate, action, formatTravelDate)}`} /> ); } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION) { @@ -1366,92 +1365,92 @@ function PureReportActionItem({ } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION) { children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.RESOLVED_DUPLICATES)) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_NAME) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUTO_REPORTING_FREQUENCY) { - children = ; + children = ; } else if ( action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CATEGORY || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.SET_CATEGORY_NAME ) { - children = ; + children = ; } else if ( action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_TAX || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_TAX || action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAX ) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_TAX_NAME) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CURRENCY_DEFAULT_TAX) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FOREIGN_CURRENCY_DEFAULT_TAX) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_TAG_LIST_NAME) { - children = ; + children = ; } else if (isTagModificationAction(action.actionName)) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_CUSTOM_UNIT_RATE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_CUSTOM_UNIT_RATE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_CUSTOM_UNIT_RATE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_REPORT_FIELD) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REPORT_FIELD) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_REPORT_FIELD) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FIELD)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FEATURE_ENABLED)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_IS_ATTENDEE_TRACKING_ENABLED)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_APPROVER)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_SUBMITS_TO)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_FORWARDS_TO)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_REIMBURSEMENT_ENABLED)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_BILLABLE)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_REIMBURSABLE)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_DEFAULT_TITLE_ENFORCED)) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_EMPLOYEE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_EMPLOYEE) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_EMPLOYEE) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_APPROVER_RULE)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_APPROVER_RULE)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_APPROVER_RULE)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN)) { - children = ; + children = ; } else if (isActionableCardFraudAlert(action)) { - const message = getActionableCardFraudAlertMessage(action, getLocalDateFromDatetime); + const message = getActionableCardFraudAlertMessage(translate, action, getLocalDateFromDatetime); children = ( - + {actionableItemButtons.length > 0 && ( ); } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.DEMOTED_FROM_WORKSPACE)) { - children = ; + children = ; } else if (isCardIssuedAction(action)) { children = ( ; } else if (isRenamedAction(action)) { - const message = getRenamedAction(action, isExpenseReport(report)); + const message = getRenamedAction(translate, action, isExpenseReport(report)); children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.INTEGRATION_SYNC_FAILED)) { children = ( - ${getIntegrationSyncFailedMessage(action, report?.policyID, isTryNewDotNVPDismissed)}`} /> + ${getIntegrationSyncFailedMessage(translate, action, report?.policyID, isTryNewDotNVPDismissed)}`} /> ); } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.ADD_INTEGRATION)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_AUDIT_RATE)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MANUAL_APPROVAL_THRESHOLD)) { - children = ; + children = ; } else if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.CREATED) && isHarvestCreatedExpenseReport) { const harvestReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportNameValuePairsOriginalID}`]; const harvestReportName = getReportName(harvestReport); @@ -1521,7 +1520,7 @@ function PureReportActionItem({ } else if (isActionableMentionWhisper(action)) { children = ( - + {actionableItemButtons.length > 0 && ( - ${getChangedApproverActionMessage(action)}`} /> + ${getChangedApproverActionMessage(translate, action)}`} /> ); } else { diff --git a/src/pages/home/report/ReportActionItemMessage.tsx b/src/pages/home/report/ReportActionItemMessage.tsx index 2cc8c5bcb07c..c780a20f4e33 100644 --- a/src/pages/home/report/ReportActionItemMessage.tsx +++ b/src/pages/home/report/ReportActionItemMessage.tsx @@ -54,13 +54,13 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true}); const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(getLinkedTransactionID(action))}`, {canBeMissing: true}); - const fragments = getReportActionMessageFragments(action); + const fragments = getReportActionMessageFragments(translate, action); const isIOUReport = isMoneyRequestAction(action); if (isMemberChangeAction(action)) { // This will be fixed: https://github.com/Expensify/App/issues/76852 // eslint-disable-next-line @typescript-eslint/no-deprecated - const fragment = getMemberChangeMessageFragment(action, getReportName); + const fragment = getMemberChangeMessageFragment(translate, action, getReportName); return ( @@ -76,7 +76,7 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid } if (action.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) { - const fragment = getUpdateRoomDescriptionFragment(action); + const fragment = getUpdateRoomDescriptionFragment(translate, action); return ( { [takeControlAction.reportActionID]: takeControlAction, }); const lastMessage = getLastMessageTextForReport({report, lastActorDetails: null, isReportArchived: false}); - expect(lastMessage).toBe(Parser.htmlToText(getChangedApproverActionMessage(takeControlAction))); + expect(lastMessage).toBe(Parser.htmlToText(getChangedApproverActionMessage(translateLocal, takeControlAction))); }); it('REROUTE action', async () => { const report: Report = createRandomReport(0, undefined); @@ -2795,7 +2795,7 @@ describe('OptionsListUtils', () => { [rerouteAction.reportActionID]: rerouteAction, }); const lastMessage = getLastMessageTextForReport({report, lastActorDetails: null, isReportArchived: false}); - expect(lastMessage).toBe(Parser.htmlToText(getChangedApproverActionMessage(rerouteAction))); + expect(lastMessage).toBe(Parser.htmlToText(getChangedApproverActionMessage(translateLocal, rerouteAction))); }); it('MOVED action', async () => { const report: Report = createRandomReport(0, undefined); diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 839911a4822f..5d2d88acc765 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -1047,7 +1047,7 @@ describe('ReportActionsUtils', () => { ], }; const expectedMessage = ReportActionsUtils.getReportActionMessageText(action); - const expectedFragments = ReportActionsUtils.getReportActionMessageFragments(action); + const expectedFragments = ReportActionsUtils.getReportActionMessageFragments(translateLocal, action); expect(expectedFragments).toEqual([{text: expectedMessage, html: `${expectedMessage}`, type: 'COMMENT'}]); }); @@ -1065,7 +1065,7 @@ describe('ReportActionsUtils', () => { // When getting the message fragments of the action const expectedMessage = ReportActionsUtils.getDynamicExternalWorkflowRoutedMessage(action, translateLocal); - const expectedFragments = ReportActionsUtils.getReportActionMessageFragments(action); + const expectedFragments = ReportActionsUtils.getReportActionMessageFragments(translateLocal, action); // Then it should return the correct message fragments expect(expectedFragments).toEqual([{text: expectedMessage, html: `${expectedMessage}`, type: 'COMMENT'}]); @@ -1311,7 +1311,7 @@ describe('ReportActionsUtils', () => { created: '1', }; const report = {...createRandomReport(2, undefined), type: CONST.REPORT.TYPE.CHAT}; - expect(ReportActionsUtils.getRenamedAction(reportAction, isExpenseReport(report), 'John')).toBe('John renamed this room to "New name" (previously "Old name")'); + expect(ReportActionsUtils.getRenamedAction(translateLocal, reportAction, isExpenseReport(report), 'John')).toBe('John renamed this room to "New name" (previously "Old name")'); }); it('should return the correct translated message for a renamed action in expense report', () => { @@ -1329,7 +1329,7 @@ describe('ReportActionsUtils', () => { }; const report = {...createRandomReport(2, undefined), type: CONST.REPORT.TYPE.EXPENSE}; - expect(ReportActionsUtils.getRenamedAction(reportAction, isExpenseReport(report), 'John')).toBe('John renamed to "New name" (previously "Old name")'); + expect(ReportActionsUtils.getRenamedAction(translateLocal, reportAction, isExpenseReport(report), 'John')).toBe('John renamed to "New name" (previously "Old name")'); }); }); describe('getCardIssuedMessage', () => { @@ -1460,7 +1460,7 @@ describe('ReportActionsUtils', () => { }, }; - const actual = ReportActionsUtils.getPolicyChangeLogUpdateEmployee(action); + const actual = ReportActionsUtils.getPolicyChangeLogUpdateEmployee(translateLocal, action); const expected = translateLocal('report.actions.type.updatedCustomField1', {email: formatPhoneNumber(email), newValue, previousValue}); expect(actual).toBe(expected); }); @@ -1501,13 +1501,11 @@ describe('ReportActionsUtils', () => { }); const expectedRoleMessage = translateLocal('report.actions.type.updateRole', { email: formattedEmail, - // eslint-disable-next-line @typescript-eslint/no-deprecated newRole: translateLocal('workspace.common.roleName', {role: newRole}).toLowerCase(), - // eslint-disable-next-line @typescript-eslint/no-deprecated currentRole: translateLocal('workspace.common.roleName', {role: previousRole}).toLowerCase(), }); - const actual = ReportActionsUtils.getPolicyChangeLogUpdateEmployee(action); + const actual = ReportActionsUtils.getPolicyChangeLogUpdateEmployee(translateLocal, action); expect(actual).toBe(`${expectedCustomFieldMessage}, ${expectedRoleMessage}`); }); }); @@ -1527,7 +1525,7 @@ describe('ReportActionsUtils', () => { }, }; - const actual = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(action); + const actual = ReportActionsUtils.getPolicyChangeLogDeleteMemberMessage(translateLocal, action); const expected = translateLocal('report.actions.type.removeMember', formatPhoneNumber(email), translateLocal('workspace.common.roleName', {role}).toLowerCase()); expect(actual).toBe(expected); });