Skip to content

[Due for payment 2025-08-11] [$250] Split scan - Description with mark down is displayed in HTML tags on the expense preview #65889

Closed

Description

@vincdargento

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.1.79-7
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/6467090
Email or phone of affected tester (no customers): applausetester+sdsdk90s@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Money Requests

Action Performed:

  1. Go to staging.expensify.com
  2. Open 1:1 DM.
  3. Click + > Split expense > Scan.
  4. Upload a photo.
  5. On the confirmation page, click Description.
  6. Enter text with any mark down and save it.
  7. Click Split expense.
  8. Click on the split preview.
  9. Manually enter amount and save it.

Expected Result:

Description with mark down will be rendered properly in mark down.

Actual Result:

Description with mark down is displayed in HTML tags on the expense preview and transaction thread.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021944911737496561361
  • Upwork Job ID: 1944911737496561361
  • Last Price Increase: 2025-07-22
  • Automatic offers:
    • mkzie2 | Contributor | 108167783
Issue OwnerCurrent Issue Owner: @RachCHopkins

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 10, 2025
  2. melvin-bot commented on Jul 10, 2025

    @melvin-bot

    Triggered auto assignment to @RachCHopkins (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. mkzie2 commented on Jul 10, 2025

    @mkzie2
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Description with mark down is displayed in HTML tags on the expense preview and transaction thread.

    What is the root cause of that problem?

    When we complete the split bill without changing the description, updatedTransaction?.comment?.comment is already the HTML tag, and it's parsed again here. So it's displayed as HTML tags on the expense preview.

    App/src/libs/actions/IOU.ts

    Lines 6924 to 6929 in ccfdb74

    const parsedComment = getParsedComment(updatedTransaction?.comment?.comment ?? '');
    if (updatedTransaction?.comment) {
    // eslint-disable-next-line no-param-reassign
    updatedTransaction.comment.comment = parsedComment;
    }
    const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(sessionEmail);

    What changes do you think we should make in order to solve the problem?

    We should convert to markdown first to ensure the parsedComment is correct.

    const parsedComment = getParsedComment(Parser.htmlToMarkdown(updatedTransaction?.comment?.comment ?? ''));
    

    App/src/libs/actions/IOU.ts

    Lines 6924 to 6929 in ccfdb74

    const parsedComment = getParsedComment(updatedTransaction?.comment?.comment ?? '');
    if (updatedTransaction?.comment) {
    // eslint-disable-next-line no-param-reassign
    updatedTransaction.comment.comment = parsedComment;
    }
    const currentUserEmailForIOUSplit = addSMSDomainIfPhoneNumber(sessionEmail);

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Update completeSplitBill unit test and verify the comment is correct format

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. dmkt9 commented on Jul 11, 2025

    @dmkt9
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Description with mark down is displayed in HTML tags on the expense preview and transaction thread.

    What is the root cause of that problem?

    1. When any field of a split transaction is changed, it is saved as a draft using the setDraftSplitTransaction utility.

      function setDraftSplitTransaction(transactionID: string | undefined, transactionChanges: TransactionChanges = {}, policy?: OnyxEntry<OnyxTypes.Policy>) {

    2. Inside setDraftSplitTransaction, if the draft transaction does not exist, it looks up the original transaction to create the draft.

      App/src/libs/actions/IOU.ts

      Lines 7178 to 7183 in d40d0af

      if (!draftSplitTransaction) {
      draftSplitTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
      }
      const updatedTransaction = draftSplitTransaction
      ? getUpdatedTransaction({

      And with this transaction the comment sent from the server is in html format.

    3. In the getUpdatedTransaction function, when creating the draft transaction, the comment is not converted back to markdown but stored directly as HTML. This causes the server to escape it again on upload, resulting in:

      const description = truncate(StringUtils.lineBreaksToSpaces(Parser.htmlToText(requestComment ?? '')), {length: CONST.REQUEST_PREVIEW.MAX_LENGTH});

      returning an HTML string.

    What changes do you think we should make in order to solve the problem?

    Ensure that comments are converted back to markdown here:

    App/src/libs/actions/IOU.ts

    Lines 7178 to 7180 in d40d0af

    if (!draftSplitTransaction) {
    draftSplitTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
    }

    if (!draftSplitTransaction) {
        draftSplitTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
        if (draftSplitTransaction?.comment?.comment) {
            draftSplitTransaction.comment = {
                ...draftSplitTransaction.comment,
                comment: Parser.htmlToMarkdown(draftSplitTransaction.comment.comment),
            };
        }
    }

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Add a test for getUpdatedTransaction và setDraftSplitTransaction to cover this scenario.

    What alternative solutions did you explore? (Optional)

    Ensure that comments are converted back to markdown whenever the description field hasn’t changed.

    if (Object.hasOwn(transactionChanges, 'comment')) {
    updatedTransaction.comment = {
    ...updatedTransaction.comment,
    comment: transactionChanges.comment,
    };
    }

    if (Object.hasOwn(transactionChanges, 'comment')) {
        updatedTransaction.comment = {
            ...updatedTransaction.comment,
            comment: transactionChanges.comment,
        };
    } else if (updatedTransaction.comment?.comment) {
        updatedTransaction.comment = {
            ...updatedTransaction.comment,
            comment: Parser.htmlToMarkdown(updatedTransaction.comment?.comment),
        };
    }

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  5. PiyushChandra17 commented on Jul 11, 2025

    @PiyushChandra17
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Split scan - Description with mark down is displayed in HTML tags on the expense preview

    What is the root cause of that problem?

    Currently we are passing shouldRenderAsHTML prop here

    which is instead of text it is using highly rich text as RenderHTML
    now,

    return titleToWrap ? `<comment>${titleToWrap}</comment>` : '';

    This line is the root cause, we need to replace HTML with markdown

    Root cause: This issue was introduced when we added RenderHTML here

    <RenderHTML html={processedTitle} />

    What changes do you think we should make in order to solve the problem?

    Update this line

    return titleToWrap ? `<comment>${titleToWrap}</comment>` : '';

    with,

    titleToWrap ? Parser.htmlToMarkdown(`<comment>${titleToWrap}</comment>`) : '';

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    N/A

    What alternative solutions did you explore? (Optional)

    N/A

    Result

    Description before
    Image

    Description after
    Image

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  6. melvin-bot commented on Jul 14, 2025

    @melvin-bot

    @RachCHopkins Whoops! This issue is 2 days overdue. Let's get this updated quick!

  7. RachCHopkins commented on Jul 15, 2025

    @RachCHopkins
    Contributor

    I don't think people would use markdown headers in an expense description. But if they did for some really weird reason, we should just render it as/convert to Bold or nothing at all.

    We should do that with anything that is not supported. e.g. if customer was to paste in something from a web listing, we should make it plain IMO.

  8. changed the title [-]Split scan - Description with mark down is displayed in HTML tags on the expense preview[/-] [+][$250] Split scan - Description with mark down is displayed in HTML tags on the expense preview[/+] on Jul 15, 2025
  9. melvin-bot commented on Jul 15, 2025

    @melvin-bot
  10. 31 remaining items

  11. changed the title [-][$250] Split scan - Description with mark down is displayed in HTML tags on the expense preview[/-] [+][Due for payment 2025-08-11] [$250] Split scan - Description with mark down is displayed in HTML tags on the expense preview[/+] on Aug 4, 2025
  12. melvin-bot commented on Aug 4, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  13. melvin-bot commented on Aug 4, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.88-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-08-11. 🎊

    For reference, here are some details about the assignees on this issue:

  14. melvin-bot commented on Aug 4, 2025

    @melvin-bot

    @dukenv0307 @RachCHopkins The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. dukenv0307 commented on Aug 5, 2025

    @dukenv0307
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production
    • 2b. Reported on staging (deploy blocker)
    • 2c. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/44523/files#r2253073031

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again. Yes

    Regression Test Proposal Template

    Regression Test Proposal

    Test:

    1. Open a group chat
    2. Create a scan split expense with the description is any markdown
    3. Open the split bill detail page
    4. Enter the amount and save it (do not change the description)
    5. Verify that the description is displayed as normal text instead of markdown in the preview

    Do we agree 👍 or 👎

  16. RachCHopkins commented on Aug 11, 2025

    @RachCHopkins
    Contributor

    Payment Summary:

    • Contributor: @mkzie2 to be paid $250 via Upwork
    • Contributor+: @dukenv0307 to be paid $250 via NewDot Manual Request

    Upwork job here

  17. RachCHopkins commented on Aug 11, 2025

    @RachCHopkins
    Contributor

    Contributor has been paid, the contract has been completed, and the Upwork post has been closed.

    @dukenv0307 you have the 🟢 to request payment.

  18. garrettmknight commented on Aug 20, 2025

    @garrettmknight
    Contributor

    $250 approved for @dukenv0307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions