diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 57c9d7ec9fe9..9d321c39ac22 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -170,12 +170,15 @@ function getSimplifiedReportObject(report) { const isLastMessageAttachment = /]+)\/>/gi.test(lastActionMessage); const chatType = lodashGet(report, ['reportNameValuePairs', 'chatType'], ''); - // We are removing any html tags from the message html since we cannot access the text version of any comments as - // the report only has the raw reportActionList and not the processed version returned by Report_GetHistory - // We convert the line-breaks in html to space ' ' before striping the tags - const lastMessageText = lastActionMessage - .replace(/((]*>)+)/gi, ' ') - .replace(/(<([^>]+)>)/gi, '') || `[${translateLocal('common.deletedCommentMessage')}]`; + let lastMessageText = null; + if (report.reportActionCount > 0) { + // We are removing any html tags from the message html since we cannot access the text version of any comments as + // the report only has the raw reportActionList and not the processed version returned by Report_GetHistory + // We convert the line-breaks in html to space ' ' before striping the tags + lastMessageText = lastActionMessage + .replace(/((]*>)+)/gi, ' ') + .replace(/(<([^>]+)>)/gi, '') || `[${translateLocal('common.deletedCommentMessage')}]`; + } const reportName = lodashGet(report, ['reportNameValuePairs', 'type']) === 'chat' ? getChatReportName(report, chatType) : report.reportName;