Skip to content

[Due for payment 2026-08-17] [$250] When a system message contains a URL, the link is displayed as raw Markdown instead of being rendered as a clickable hyperlink. #96687

Closed

Description

@m-natarajan

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.41-2
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @JmillsExpensify
Slack conversation (hyperlinked to channel name): #Expensify Bugs

Action Performed:

  1. Create an expense report.
  2. Add a description containing a URL/link.
  3. Update the description with a different URL/link.
  4. Observe the system message generated after the description change.

Expected Result:

The URL in the system message should be rendered as a clickable hyperlink.
The updated description link should display correctly without exposing raw Markdown formatting.

Actual Result:

The URL appears as Markdown text instead of a clickable hyperlink in the system message.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

Image Image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    Melvin TriageAutomatic AI Analysis of an issue
    and removed
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 21, 2026
  2. added
    ExternalAdded to denote the issue can be worked on by a contributor
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 23, 2026
  3. samranahm commented on Jul 23, 2026

    @samranahm
    Contributor

    Proposal

    What is the root cause of that problem?

    When a user updates an expense report description from one URL to another, NewDot builds a system message like "changed the description to ...". The new and old descriptions are wrapped into Markdown links so they render as clickable text, and the link label is passed through escapeLinkText in MarkdownLinkHelpers.ts:

    const escapeLinkText = (text: string): string => {
    if (!text) {
    return '';
    }
    const collapsed = text
    .replaceAll(/\r?\n+/g, ' ')
    .replaceAll(/\s+/g, ' ')
    .trim();
    return collapsed.replaceAll('[', '[').replaceAll(']', ']');
    };

    escapeLinkText replaces every [ and ] with the HTML entities [ and ]. When the description itself is a Markdown link such as [label](https://example.com), the surrounding brackets get escaped, so the resulting string is no longer valid Markdown link syntax. The renderer then prints the raw entity-escaped Markdown (the [...](...) text) instead of producing a clickable hyperlink, which is exactly what the screenshots show.

    Because the escaping is applied unconditionally to the whole description, a description that is (or contains) a URL/Markdown link is corrupted before it reaches the Markdown parser, so the link never renders.

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

    1. In MarkdownLinkHelpers.ts, escapeLinkText currently escapes brackets even when the incoming text is already a valid URL or Markdown link. Detect that case and preserve the link so the parser can render it:

    const escapeLinkText = (text: string): string => {
    if (!text) {
    return '';
    }
    const collapsed = text
    .replaceAll(/\r?\n+/g, ' ')
    .replaceAll(/\s+/g, ' ')
    .trim();
    return collapsed.replaceAll('[', '[').replaceAll(']', ']');
    };

    const escapeLinkText = (text: string): string => {
        if (!text) {
            return '';
        }
        const collapsed = text
            .replaceAll(/\r?\n+/g, ' ')
            .replaceAll(/\s+/g, ' ')
            .trim();
    
        // If the value is already a URL or a Markdown link, leave brackets intact so it renders as a hyperlink
        if (Str.isValidURL(collapsed) || CONST.REGEX.MARKDOWN_LINK?.test(collapsed)) {
            return collapsed;
        }
    
        return collapsed.replaceAll('[', '[').replaceAll(']', ']');
    };
    1. Confirm the callers that build the description-change system message use this helper only for plain label text, not for content that is itself a URL. When the new/old description is a bare URL, the message should render it directly as a link rather than double-wrapping it in Markdown that then gets escaped.

    This keeps the whitespace collapsing behavior intact for normal labels while ensuring URL/Markdown-link descriptions survive escaping and render as clickable hyperlinks in the system message.

    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. ahmdshrif commented on Jul 23, 2026

    @ahmdshrif
    Contributor

    Proposal

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

    When an expense description containing a URL is added or updated, the resulting system message ("changed the description to …") shows the link as raw Markdown ([text](url)) / plain text instead of a clickable hyperlink.

    What is the root cause of that problem?

    The structural cause: getForReportAction builds an HTML message, but the description fragment is the one field that injects Markdown into it. The HTML renderer does not parse Markdown, so the Markdown source shows literally.

    The verified chain:

    1. Descriptions are stored as HTML: updateMoneyRequestDescription parses the typed text with getParsedComment (ExpensiMark → HTML), so a URL becomes <a href="…">…</a>:
      const parsedComment = getParsedComment(comment);
      const transactionChanges: TransactionChanges = {
      comment: parsedComment,
      };
      . That HTML lands in originalMessage.newComment/oldComment:

      App/src/libs/ReportUtils.ts

      Lines 6133 to 6138 in 0169d32

      // Remark: Comment field is the only one which has new/old prefixes for the keys (newComment/ oldComment),
      // all others have old/- pattern such as oldCreated/created
      if ('comment' in transactionChanges) {
      originalMessage.oldComment = getDescription(oldTransaction);
      originalMessage.newComment = transactionChanges?.comment;
      }
    2. The description fragment converts that HTML to Markdown via Parser.htmlToMarkdown, producing [text](url):
      buildMessageFragmentForValue(
      translate,
      Parser.htmlToMarkdown(reportActionOriginalMessage?.newComment ?? ''),
      Parser.htmlToMarkdown(reportActionOriginalMessage?.oldComment ?? ''),
      descriptionLabel,
      true,
      setFragments,
      removalFragments,
      changeFragments,
      );
    3. The message is rendered as HTML, not Markdown: ModifiedExpenseContent → ReportActionItemMessageWithExplain feeds it straight into RenderHTML, which shows the Markdown characters verbatim — the reported symptom:
      return (
      <ReportActionItemBasicMessage>
      <RenderHTML
      html={`<comment><muted-text>${computedMessage}</muted-text></comment>`}
      isSelectable={!canUseTouchScreen() || !shouldUseNarrowLayout}
      onLinkPress={handleLinkPress}
      />
      </ReportActionItemBasicMessage>
    4. The HTML contract is explicit in the same message: the MCC category fragment and the appended Explain link are raw <a> tags that render correctly today —
      basedOnMCC: ({rulesLink}: {rulesLink: string}) => (rulesLink ? `based on <a href="${rulesLink}">workspace rules</a>` : 'based on workspace rule'),
      and
      AskToExplain: `. <a href="${CONST.CONCIERGE_EXPLAIN_LINK_PATH}">Explain<sparkles-icon/></a>`,
      . The description fragment is the only Markdown producer.

    This is a leftover, not intent: the conversion came from PR #44523, when this message was rendered as plain text and showing Markdown source was correct. The pipeline has since moved to HTML, and every consumer now treats the return value as HTML, so the stale conversion breaks all of them:

    • Chat system message (main repro): RenderHTML (link above).
    • LHN last-message preview: htmlToText leaves the Markdown visible —
      } else if (isModifiedExpenseAction(lastReportAction)) {
      const properSchemaForModifiedExpenseMessageWithHTML = getForReportAction({
      translate,
      reportAction: lastReportAction,
      policy,
      movedFromReport,
      movedToReport,
      policyTags,
      currentUserLogin: currentUserLogin ?? '',
      });
      // Strip HTML tags for plain text display in options list
      const properSchemaForModifiedExpenseMessage = Parser.htmlToText(properSchemaForModifiedExpenseMessageWithHTML);
      lastMessageTextFromReport = formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true);
    • Report/thread preview name: same strip —
      const modifiedMessageWithHTML = getForReportAction({
      translate,
      reportAction: parentReportAction,
      movedFromReport,
      movedToReport,
      policyTags,
      policy,
      currentUserLogin,
      });
      // Strip HTML tags for plain text display in report previews
      const modifiedMessage = Parser.htmlToText(modifiedMessageWithHTML);
      return formatReportLastMessageText(modifiedMessage);
    • Browser notification body: getTextFromHtml —
      const bodyWithHTML = getForReportAction({
      translate: translateLocal,
      reportAction,
      policy,
      movedFromReport,
      movedToReport,
      policyTags,
      currentUserLogin,
      reportAttributes,
      });
      // Strip HTML tags for plain text notification body
      const body = getTextFromHtml(bodyWithHTML);
    • Copy-to-clipboard: runs htmlToMarkdown on a string already containing Markdown, escaping it (\[url\]) —
      const modifyExpenseMessageWithHTML = getForReportAction({
      translate,
      reportAction,
      policy,
      movedFromReport,
      movedToReport,
      policyTags,
      currentUserLogin: currentUserPersonalDetails?.email ?? '',
      });
      // Convert HTML to markdown for clipboard copy to preserve links and formatting
      const modifyExpenseMessage = Parser.htmlToMarkdown(modifyExpenseMessageWithHTML);
      Clipboard.setString(modifyExpenseMessage);
    • Second in-file call site, identical bug: the rules-modified message's comment key —
      // The backend saves the description field as `comment` key, but we need to display it as `description` key.
      if (key === 'comment') {
      return translate('iou.rulesModifiedFields.common', 'description', Parser.htmlToMarkdown(updatedValue), isFirst);
      }

    This explains every symptom detail: raw Markdown visible, link not clickable, all platforms (shared code path), and only the description field affected (other fields are plain scalar values).

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

    Stop converting the stored HTML to Markdown — pass it through, matching the function's HTML contract. In src/libs/ModifiedExpenseMessage.ts (both call sites):

    // getForReportAction, description fragment (~L360):
    buildMessageFragmentForValue(
        translate,
        reportActionOriginalMessage?.newComment ?? '',
        reportActionOriginalMessage?.oldComment ?? '',
        ...
    // getRulesModifiedMessage (~L250):
    return translate('iou.rulesModifiedFields.common', 'description', updatedValue, isFirst);

    Every surface then inherits correctness from its existing per-surface conversion: RenderHTML renders a real clickable <a> in chat; htmlToText/getTextFromHtml yield clean plain text for LHN/previews/notifications; clipboard does exactly one htmlToMarkdown pass. The fix removes a conversion instead of adding one. I'd add a URL case to tests/unit/ModifiedExpenseMessageTest.ts.

    Regression safety in one sentence: all five consumers already treat the return value as HTML (their variables are literally named …WithHTML) and sibling fragments already embed <a> tags, so no consumer reads the description fragment as Markdown and non-description fields are untouched.

    Why the obvious spot fix fails: converting the final message with Parser.replace(...) at the render sink does not work — ExpensiMark's replace() HTML-escapes its input, so the legitimate <a> tags already inside the same string (the MCC "workspace rules" link and the appended Explain link) would be escaped into visible literal tags; and it only fixes chat, leaving LHN previews, notifications, and clipboard still emitting raw/escaped Markdown because they never pass through that sink.

    What alternative solutions did you explore? (Optional)

    1. Parser.replace in ReportActionItemMessageWithExplain/ModifiedExpenseContent — the spot fix; incomplete and self-defeating as shown above.
    2. Converting the description Markdown back to HTML after building fragments — a circular html → markdown → html round trip adding runtime work and lossy edge cases; passing the stored HTML through removes the conversion entirely.
    3. The server-side ModifiedExpense::getNewDotComment mirror can be aligned in a follow-up; the App recomputes this message locally, so this in-repo change fully fixes the bug on its own.
  5. wildan-m commented on Jul 23, 2026

    @wildan-m
    Contributor

    Proposal

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

    When an expense's description contains a URL and the description is edited, the system message in the report ("changed the description to ... (previously ...)") displays the link as raw Markdown — for example [https://example.com](https://example.com) — instead of rendering it as a clickable hyperlink.

    What is the root cause of that problem?

    Expense descriptions are stored as HTML. When a description is saved, the text is run through the Markdown parser, so a bare URL becomes an HTML anchor. This is true both for the server-stored value and for the optimistic update, which parses the comment before writing it:

    const parsedComment = getParsedComment(comment);
    const transactionChanges: TransactionChanges = {
    comment: parsedComment,
    };

    The system message for a modified expense is built client-side by getForReportAction in ModifiedExpenseMessage.ts. For the description field, it converts the stored old/new HTML values into Markdown using Parser.htmlToMarkdown:

    buildMessageFragmentForValue(
    translate,
    Parser.htmlToMarkdown(reportActionOriginalMessage?.newComment ?? ''),
    Parser.htmlToMarkdown(reportActionOriginalMessage?.oldComment ?? ''),
    descriptionLabel,
    true,
    setFragments,
    removalFragments,
    changeFragments,
    );

    However, the string this function returns is consumed as HTML everywhere. The chat message is injected directly into RenderHTML by ReportActionItemMessageWithExplain (used by ModifiedExpenseContent, the renderer for modified-expense actions):

    <RenderHTML
    html={`<comment><muted-text>${computedMessage}</muted-text></comment>`}
    isSelectable={!canUseTouchScreen() || !shouldUseNarrowLayout}
    onLinkPress={handleLinkPress}
    />

    RenderHTML renders HTML tags, but Markdown link syntax is not HTML, so the literal characters [text](url) are displayed as-is in the system message — exactly what the screenshots show.

    Every other consumer of getForReportAction also treats the result as HTML: the LHN preview strips it with Parser.htmlToText, the browser notification strips it with getTextFromHtml, the report-name fallback strips it with Parser.htmlToText, and the context-menu copy converts it with Parser.htmlToMarkdown:

    const properSchemaForModifiedExpenseMessage = Parser.htmlToText(properSchemaForModifiedExpenseMessageWithHTML);

    Because the description fragment is Markdown rather than HTML, those strip/convert calls are no-ops on it — which is why the raw [text](url) also leaks into the LHN last-message preview.

    That the message pipeline is HTML-based is confirmed by sibling fragments in the same function: the category-change fragment already embeds an HTML anchor for the workspace-rules link (the "based on MCC" attribution) and it renders as a clickable link through this exact path.

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

    In getForReportAction in ModifiedExpenseMessage.ts, stop converting the description values to Markdown: pass reportActionOriginalMessage.newComment and reportActionOriginalMessage.oldComment to buildMessageFragmentForValue directly (removing the two Parser.htmlToMarkdown wrappers), so the description fragment carries the stored HTML.

    With that single change, every consumer behaves correctly by construction:

    • The chat system message renders through RenderHTML, so the anchor becomes a clickable hyperlink, matching the expected result.
    • The LHN preview, browser notification, and report-name fallback strip the HTML tags and show clean plain text (this also fixes the raw-Markdown leak in the LHN preview).
    • Copying the message from the context menu still yields Markdown, since that path converts the HTML with Parser.htmlToMarkdown — unchanged behavior.

    The same mismatch exists in the rules-modified branch of the same file (getRulesModifiedMessage, where the backend's comment field is likewise converted with Parser.htmlToMarkdown before display), and it should receive the identical one-line treatment for consistency:

    // The backend saves the description field as `comment` key, but we need to display it as `description` key.
    if (key === 'comment') {
    return translate('iou.rulesModifiedFields.common', 'description', Parser.htmlToMarkdown(updatedValue), isFirst);
    }

    Those are the only three uses of the Markdown parser in this file, so its import becomes unused and is removed as well.

    Existing unit tests in ModifiedExpenseMessageTest.ts use plain-text descriptions, for which the conversion was a no-op, so they remain valid; a test asserting that an HTML description passes through unmodified can be added. Note the file's doc comment says the backend's ModifiedExpense::getNewDotComment mirrors this function — the backend's HTML message variant can be aligned the same way, but the display fix for New Expensify is entirely client-side since the app rebuilds this message locally from originalMessage.

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/96687-description-link-html?expand=1

    What alternative solutions did you explore? (Optional)

    Converting the finished message from Markdown to HTML at the render site (running the parser over it in ModifiedExpenseContent before handing it to RenderHTML). Rejected: the built message can already contain legitimate HTML (the MCC-based category attribution embeds an anchor), which re-parsing with text escaping would mangle, and it would fix only the chat rendering while leaving the raw-Markdown leak in the LHN preview and notifications, all of which expect HTML input from this function.

  6. melvin-bot commented on Jul 23, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (External)

  7. 52 remaining items

  8. mananjadhav commented on Aug 16, 2026

    @mananjadhav
    Collaborator

    Contributor+ Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to the comment on the PR: Couldn't pinpoint to the exact PR where we should've supported HTML for preview description.
      Link to the comment on the Issue: NA

    • [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:

    • [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.

    Regression Test Proposal

    Test:

    1. Create an expense (e.g. Track/Submit an expense to yourself).
    2. Set the description to a URL, e.g. https://old.example.com.
    3. Edit the description again to a different URL, e.g. https://new.example.com.
    4. Verify the resulting "changed the description to …" system message renders both the old and new descriptions as clickable hyperlinks, not raw [text](url) Markdown text.
    5. Verify the LHN last-message preview and thread name show clean plain text (no visible Markdown syntax).

    Do we agree 👍 or 👎

  9. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Aug 16, 2026
  10. melvin-bot commented on Aug 16, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  11. melvin-bot commented on Aug 16, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
  12. mallenexpensify commented on Aug 18, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @ahmdshrif paid $250 via Upwork
    Contributor+: @mananjadhav due $250 via NewDot

  13. mananjadhav commented on Aug 18, 2026

    @mananjadhav
    Collaborator

    @mallenexpensify Can you correct the name for C+ here?

  14. mallenexpensify commented on Aug 18, 2026

    @mallenexpensify
    Contributor

    @mananjadhav done. GH can suck sometimes

    Image
  15. mananjadhav commented on Aug 18, 2026

    @mananjadhav
    Collaborator

    Yes I can relate 😬 Thanks for the quick action.

  16. garrettmknight commented on Aug 25, 2026

    @garrettmknight
    Contributor

    $250 approved for @mananjadhav

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 contributorMelvin TriageAutomatic AI Analysis of an issue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions