From b558ab5db18d0e11cd4893b8acd2d284f868f5c2 Mon Sep 17 00:00:00 2001 From: AngelNBazan Date: Tue, 30 May 2023 16:45:20 -0700 Subject: [PATCH 1/2] Fix: Parser Bug in IOU --- src/components/ReportActionItem/IOUPreview.js | 2 +- src/libs/ReportUtils.js | 11 ++++------- src/libs/actions/IOU.js | 12 ++++-------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index ab706197351a..1f812ba43885 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -141,7 +141,7 @@ const IOUPreview = (props) => { const requestAmount = moneyRequestAction.amount; const requestCurrency = moneyRequestAction.currency; - const requestComment = Str.htmlDecode(moneyRequestAction.comment).trim(); + const requestComment = moneyRequestAction.comment.trim(); const getSettledMessage = () => { switch (lodashGet(props.action, 'originalMessage.paymentType', '')) { diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index ee822f700508..b271661c2f03 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1269,7 +1269,7 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType = return [ { - html: getParsedComment(iouMessage), + html: iouMessage, text: iouMessage, isEdited: false, type: CONST.REPORT.MESSAGE.TYPE.COMMENT, @@ -1294,13 +1294,10 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType = */ function buildOptimisticIOUReportAction(type, amount, currency, comment, participants, transactionID, paymentType = '', iouReportID = '', isSettlingUp = false, isSendMoneyFlow = false) { const IOUReportID = iouReportID || generateReportID(); - const parser = new ExpensiMark(); - const commentText = getParsedComment(comment); - const textForNewComment = parser.htmlToText(commentText); - const textForNewCommentDecoded = Str.htmlDecode(textForNewComment); + const originalMessage = { amount, - comment: textForNewComment, + comment, currency, IOUTransactionID: transactionID, IOUReportID, @@ -1330,7 +1327,7 @@ function buildOptimisticIOUReportAction(type, amount, currency, comment, partici avatar: lodashGet(currentUserPersonalDetails, 'avatar', UserUtils.getDefaultAvatar(currentUserEmail)), isAttachment: false, originalMessage, - message: getIOUReportActionMessage(type, amount, textForNewCommentDecoded, currency, paymentType, isSettlingUp), + message: getIOUReportActionMessage(type, amount, comment, currency, paymentType, isSettlingUp), person: [ { style: 'strong', diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 2f710d5a88a5..26ddd30bceb3 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -348,14 +348,13 @@ function requestMoney(report, amount, currency, payeeEmail, participant, comment ); // STEP 6: Make the request - const parsedComment = ReportUtils.getParsedComment(comment); API.write( 'RequestMoney', { debtorEmail: payerEmail, amount, currency, - comment: parsedComment, + comment, iouReportID: iouReport.reportID, chatReportID: chatReport.reportID, transactionID: optimisticTransaction.transactionID, @@ -628,7 +627,6 @@ function createSplitsAndOnyxData(participants, currentUserLogin, amount, comment */ function splitBill(participants, currentUserLogin, amount, comment, currency, existingGroupChatReportID = '') { const {groupData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, amount, comment, currency, existingGroupChatReportID); - const parsedComment = ReportUtils.getParsedComment(comment); API.write( 'SplitBill', @@ -637,7 +635,7 @@ function splitBill(participants, currentUserLogin, amount, comment, currency, ex amount, splits: JSON.stringify(splits), currency, - comment: parsedComment, + comment, transactionID: groupData.transactionID, reportActionID: groupData.reportActionID, createdReportActionID: groupData.createdReportActionID, @@ -657,7 +655,6 @@ function splitBill(participants, currentUserLogin, amount, comment, currency, ex */ function splitBillAndOpenReport(participants, currentUserLogin, amount, comment, currency) { const {groupData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, amount, comment, currency); - const parsedComment = ReportUtils.getParsedComment(comment); API.write( 'SplitBillAndOpenReport', @@ -666,7 +663,7 @@ function splitBillAndOpenReport(participants, currentUserLogin, amount, comment, amount, splits: JSON.stringify(splits), currency, - comment: parsedComment, + comment, transactionID: groupData.transactionID, reportActionID: groupData.reportActionID, createdReportActionID: groupData.createdReportActionID, @@ -825,12 +822,11 @@ function buildPayPalPaymentUrl(amount, submitterPayPalMeAddress, currency) { */ function getSendMoneyParams(report, amount, currency, comment, paymentMethodType, managerEmail, recipient) { const recipientEmail = OptionsListUtils.addSMSDomainIfPhoneNumber(recipient.login); - const parsedComment = ReportUtils.getParsedComment(comment); const newIOUReportDetails = JSON.stringify({ amount, currency, requestorEmail: recipientEmail, - comment: parsedComment, + comment, idempotencyKey: Str.guid(), }); From 4c303639036d00bd69d7b2aae38c44524d7084ed Mon Sep 17 00:00:00 2001 From: AngelNBazan Date: Tue, 30 May 2023 17:13:46 -0700 Subject: [PATCH 2/2] Removed STR --- src/components/ReportActionItem/IOUPreview.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index 1f812ba43885..902c724aa614 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -4,7 +4,6 @@ import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; import _ from 'underscore'; -import Str from 'expensify-common/lib/str'; import compose from '../../libs/compose'; import styles from '../../styles/styles'; import ONYXKEYS from '../../ONYXKEYS';