diff --git a/src/languages/en.ts b/src/languages/en.ts index e0ed30050bb13..f295f4576e1ba 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3686,7 +3686,8 @@ export default { reimbursementACHCancelled: `canceled the payment`, reimbursementAccountChanged: `couldn’t process the payment, as the payer changed bank accounts`, reimbursementDelayed: `processed the payment but it’s delayed by 1-2 more business days`, - selectedForRandomAudit: `[randomly selected](https://help.expensify.com/articles/expensify-classic/reports/Set-a-random-report-audit-schedule) for review`, + selectedForRandomAudit: `randomly selected for review`, + selectedForRandomAuditMarkdown: `[randomly selected](https://help.expensify.com/articles/expensify-classic/reports/Set-a-random-report-audit-schedule) for review`, share: ({to}: ShareParams) => `invited user ${to}`, unshare: ({to}: UnshareParams) => `removed user ${to}`, stripePaid: ({amount, currency}: StripePaidParams) => `paid ${currency}${amount}`, diff --git a/src/languages/es.ts b/src/languages/es.ts index e56ae303a8139..8f0ac9fa57734 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3743,7 +3743,8 @@ export default { reimbursementACHCancelled: `canceled the payment`, reimbursementAccountChanged: `no se pudo procesar el pago porque el pagador cambió de cuenta bancaria`, reimbursementDelayed: `procesó el pago pero se retrasó entre 1 y 2 días hábiles más`, - selectedForRandomAudit: `[seleccionado al azar](https://help.expensify.com/articles/expensify-classic/reports/Set-a-random-report-audit-schedule) para revisión`, + selectedForRandomAudit: `seleccionado al azar para revisión`, + selectedForRandomAuditMarkdown: `[seleccionado al azar](https://help.expensify.com/articles/expensify-classic/reports/Set-a-random-report-audit-schedule) para revisión`, share: ({to}: ShareParams) => `usuario invitado ${to}`, unshare: ({to}: UnshareParams) => `usuario eliminado ${to}`, stripePaid: ({amount, currency}: StripePaidParams) => `pagado ${currency}${amount}`, diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index d7614139927fd..ebe4ffdbe53a7 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -740,7 +740,7 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails } else if (lastReportAction?.actionName === 'EXPORTINTEGRATION') { lastMessageTextFromReport = ReportActionUtils.getExportIntegrationLastMessageText(lastReportAction); } else if (lastReportAction?.actionName && ReportActionUtils.isOldDotReportAction(lastReportAction)) { - lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction); + lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction, false); } return lastMessageTextFromReport || (report?.lastMessageText ?? ''); diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 73784873201ac..6d4e603e95216 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1143,28 +1143,6 @@ function getTextFromHtml(html?: string): string { return html ? Parser.htmlToText(html) : ''; } -function getMemberChangeMessageFragment(reportAction: OnyxEntry): Message { - const messageElements: readonly MemberChangeMessageElement[] = getMemberChangeMessageElements(reportAction); - const html = messageElements - .map((messageElement) => { - switch (messageElement.kind) { - case 'userMention': - return `${messageElement.content}`; - case 'roomReference': - return `${messageElement.roomName}`; - default: - return messageElement.content; - } - }) - .join(''); - - return { - html: `${html}`, - text: getReportActionMessage(reportAction) ? getReportActionText(reportAction) : '', - type: CONST.REPORT.MESSAGE.TYPE.COMMENT, - }; -} - function isOldDotLegacyAction(action: OldDotReportAction | PartialReportAction): action is PartialReportAction { return [ CONST.REPORT.ACTIONS.TYPE.DELETED_ACCOUNT, @@ -1221,7 +1199,7 @@ function getMessageOfOldDotLegacyAction(legacyAction: PartialReportAction) { /** * Helper method to format message of OldDot Actions. */ -function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldDotReportAction): string { +function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldDotReportAction, withMarkdown = true): string { if (isOldDotLegacyAction(oldDotAction)) { return getMessageOfOldDotLegacyAction(oldDotAction); } @@ -1269,7 +1247,7 @@ function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldD case CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DELAYED: return Localize.translateLocal('report.actions.type.reimbursementDelayed'); case CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT: - return Localize.translateLocal('report.actions.type.selectedForRandomAudit'); + return Localize.translateLocal(`report.actions.type.selectedForRandomAudit${withMarkdown ? 'Markdown' : ''}`); case CONST.REPORT.ACTIONS.TYPE.SHARE: return Localize.translateLocal('report.actions.type.share', {to: originalMessage.to}); case CONST.REPORT.ACTIONS.TYPE.UNSHARE: @@ -1281,11 +1259,47 @@ function getMessageOfOldDotReportAction(oldDotAction: PartialReportAction | OldD } } +function getMemberChangeMessageFragment(reportAction: OnyxEntry): Message { + const messageElements: readonly MemberChangeMessageElement[] = getMemberChangeMessageElements(reportAction); + const html = messageElements + .map((messageElement) => { + switch (messageElement.kind) { + case 'userMention': + return `${messageElement.content}`; + case 'roomReference': + return `${messageElement.roomName}`; + default: + return messageElement.content; + } + }) + .join(''); + + return { + html: `${html}`, + text: getReportActionMessage(reportAction) ? getReportActionText(reportAction) : '', + type: CONST.REPORT.MESSAGE.TYPE.COMMENT, + }; +} + function getMemberChangeMessagePlainText(reportAction: OnyxEntry): string { const messageElements = getMemberChangeMessageElements(reportAction); return messageElements.map((element) => element.content).join(''); } +function getReportActionMessageFragments(action: ReportAction): Message[] { + if (isOldDotReportAction(action)) { + const oldDotMessage = getMessageOfOldDotReportAction(action); + const html = isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SELECTED_FOR_RANDOM_AUDIT) ? Parser.replace(oldDotMessage) : oldDotMessage; + return [{text: oldDotMessage, html: `${html}`, type: 'COMMENT'}]; + } + + const actionMessage = action.previousMessage ?? action.message; + if (Array.isArray(actionMessage)) { + return actionMessage.filter((item): item is Message => !!item); + } + return actionMessage ? [actionMessage] : []; +} + /** * Helper method to determine if the provided accountID has submitted an expense on the specified report. * @@ -1555,6 +1569,7 @@ export { getLinkedTransactionID, getMemberChangeMessageFragment, getMemberChangeMessagePlainText, + getReportActionMessageFragments, getMessageOfOldDotReportAction, getMostRecentIOURequestActionID, getMostRecentReportActionLastModified, diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index b5ee3607f3594..0cd9329da9d6e 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -634,9 +634,6 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) { children = ; - } else if (ReportActionsUtils.isOldDotReportAction(action)) { - // This handles all historical actions from OldDot that we just want to display the message text - children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) { diff --git a/src/pages/home/report/ReportActionItemMessage.tsx b/src/pages/home/report/ReportActionItemMessage.tsx index d97a7218bf7f7..4c9ed8bc78ff6 100644 --- a/src/pages/home/report/ReportActionItemMessage.tsx +++ b/src/pages/home/report/ReportActionItemMessage.tsx @@ -12,7 +12,6 @@ import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ReportAction, Transaction} from '@src/types/onyx'; -import type {Message} from '@src/types/onyx/ReportAction'; import TextCommentFragment from './comment/TextCommentFragment'; import ReportActionItemFragment from './ReportActionItemFragment'; @@ -42,13 +41,7 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID, const styles = useThemeStyles(); const {translate} = useLocalize(); - const actionMessage = action.previousMessage ?? action.message; - let fragments: Message[] = []; - if (Array.isArray(actionMessage)) { - fragments = actionMessage.filter((item): item is Message => !!item); - } else { - fragments = actionMessage ? [actionMessage] : []; - } + const fragments = ReportActionsUtils.getReportActionMessageFragments(action); const isIOUReport = ReportActionsUtils.isMoneyRequestAction(action); if (ReportActionsUtils.isMemberChangeAction(action)) {