Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Parser Bug in IOU #19868

Merged
merged 2 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/IOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
AngelNBazan marked this conversation as resolved.
Show resolved Hide resolved

const getSettledMessage = () => {
switch (lodashGet(props.action, 'originalMessage.paymentType', '')) {
Expand Down
11 changes: 4 additions & 7 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
12 changes: 4 additions & 8 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand All @@ -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,
Expand All @@ -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',
Expand All @@ -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,
Expand Down Expand Up @@ -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(),
});

Expand Down