Skip to content

Commit

Permalink
fix modifiedExpenseMessage case
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanDylann committed Sep 27, 2023
1 parent 26bba7f commit 13d94b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,7 @@ const CONST = {
EMOJI_NAME: /:[\w+-]+:/g,
EMOJI_SUGGESTIONS: /:[a-zA-Z0-9_+-]{1,40}$/,
AFTER_FIRST_LINE_BREAK: /\n.*/g,
LINE_BREAK: /\n/g,
CODE_2FA: /^\d{6}$/,
ATTACHMENT_ID: /chat-attachments\/(\d+)/,
HAS_COLON_ONLY_AT_THE_BEGINNING: /^:[^:]+$/,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ function getLastMessageTextForReport(report) {
const iouReport = ReportUtils.getReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction));
lastMessageTextFromReport = ReportUtils.getReportPreviewMessage(iouReport, lastReportAction);
} else if (ReportActionUtils.isModifiedExpenseAction(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getModifiedExpenseMessage(lastReportAction);
const properSchemaForModifiedExpenseMessage = ReportUtils.getModifiedExpenseMessage(lastReportAction);
lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true);
} else {
lastMessageTextFromReport = report ? report.lastMessageText || '' : '';

Expand Down
6 changes: 5 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,13 @@ function canShowReportRecipientLocalTime(personalDetails, report, accountID) {
/**
* Shorten last message text to fixed length and trim spaces.
* @param {String} lastMessageText
* @param {Boolean} isModifiedExpenseMessage
* @returns {String}
*/
function formatReportLastMessageText(lastMessageText) {
function formatReportLastMessageText(lastMessageText, isModifiedExpenseMessage = false) {
if (isModifiedExpenseMessage) {
return String(lastMessageText).trim().replace(CONST.REGEX.LINE_BREAK, '').trim();
}
return String(lastMessageText).trim().replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim();
}

Expand Down

0 comments on commit 13d94b3

Please sign in to comment.