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

Reports - Description with mark down is rendered as HTML tag #58268

Open
8 tasks done
mitarachim opened this issue Mar 12, 2025 · 17 comments
Open
8 tasks done

Reports - Description with mark down is rendered as HTML tag #58268

mitarachim opened this issue Mar 12, 2025 · 17 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Reviewing Has a PR in review Weekly KSv2

Comments

@mitarachim
Copy link

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.11-4
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): applausetester+110301kh@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Search

Action Performed:

  1. Go to staging.new.expensify.com
  2. Log in with a new account.
  3. Submit an expense to a user, with text containing mark down as description. Do not enter merchant.
  4. Go to Reports.

Expected Result:

Description field will not show the mark down as HTML tag.

Actual Result:

Description field shows the mark down as HTML tag.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6768397_1741770460004.20250312_170331.mp4

View all open jobs on GitHub

@mitarachim mitarachim added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 DeployBlocker Indicates it should block deploying the API DeployBlockerCash This issue or pull request should block deployment labels Mar 12, 2025
Copy link

melvin-bot bot commented Mar 12, 2025

Triggered auto assignment to @Beamanator (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Mar 12, 2025

Triggered auto assignment to @sakluger (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.

Copy link

melvin-bot bot commented Mar 12, 2025

💬 A slack conversation has been started in #expensify-open-source

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Mar 12, 2025
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@daledah
Copy link
Contributor

daledah commented Mar 12, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-03-12 09:47:25 UTC.

Proposal

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

Description field shows the mark down as HTML tag.

What is the root cause of that problem?

It seems that BE is returning description in a different format which makes the parse function we are using here wrong.

if (!merchantOrDescriptionToDisplay && !isLargeScreenWidth) {
merchantOrDescriptionToDisplay = Parser.htmlToText(Parser.replace(description));
}
let merchant = transactionItem.shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(Parser.replace(description));

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

We should remove Parser.replace(description) only use Parser.htmlToText(description)

    if (!merchantOrDescriptionToDisplay && !isLargeScreenWidth) {
        merchantOrDescriptionToDisplay = Parser.htmlToText(description);
    }
    let merchant = transactionItem.shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(description);
Image

OR we can use Parser.htmlToMarkdown if we want to show markdown

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

None

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.

@daledah
Copy link
Contributor

daledah commented Mar 12, 2025

@Beamanator I can help to raise a quick PR if needed.

@mountiny
Copy link
Contributor

@Krishna2323 @mananjadhav is this from your PR too?

@mountiny mountiny added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 DeployBlocker Indicates it should block deploying the API labels Mar 12, 2025
@mountiny
Copy link
Contributor

This is edge case, no need to block

@Beamanator
Copy link
Contributor

Sounds good to me!

@Beamanator
Copy link
Contributor

@mountiny mind linking the PR you are thinking?

@dominictb
Copy link
Contributor

dominictb commented Mar 12, 2025

This came from my PR #44523. Will push a fix PR in several hours.

@Beamanator
Copy link
Contributor

Thank you!!

@yaqoob2ishaq4
Copy link

Proposal

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

The issue arises when submitting an expense with markdown in the description. The description is incorrectly rendered with raw HTML tags instead of the expected markdown format. This issue is reproducible on the staging environment but not on production.

What is the root cause of that problem?

The problem stems from how the description field is being processed and rendered. The current approach using Parser.replace(description) and Parser.htmlToText is not adequately handling the markdown content, causing raw HTML tags to be displayed instead of the expected rendering.

The issue occurs because the system is not correctly formatting the description when displaying it in the Reports section. This discrepancy arises due to the improper parsing mechanism in place, as seen in the original code.

File: App/src/components/SelectionList/Search/TransactionListItemRow.tsx
Lines: 150–153

if (!merchantOrDescriptionToDisplay && !isLargeScreenWidth) { 
    merchantOrDescriptionToDisplay = Parser.htmlToText(Parser.replace(description)); 
} 
let merchant = transactionItem.shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(Parser.replace(description));

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

We can solve this issue by applying a more tailored approach using the HTMLElementModel.fromCustomModel method, which will handle the markdown parsing and rendering appropriately. By defining a custom model for the comment tag, we can ensure that the description is parsed and displayed as expected.

merchantOrDescriptionToDisplay = HTMLElementModel.fromCustomModel({
        tagName: 'comment',
        getMixedUAStyles: (tnode) => ({
            whiteSpace: 'pre',
            ...(tnode.attributes.islarge === undefined ? {} : styles.onlyEmojisText)
        }),
        contentModel: HTMLContentModel.block,
    }).toString(description);

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

Test Case 1: Ensure that markdown content in the description is displayed correctly (i.e., no raw HTML tags, proper rendering of markdown elements like bold, italics, links, etc.).
Test Case 2: Verify that descriptions with emoji handling (via the islarge attribute) are parsed and rendered correctly.

What alternative solutions did you explore? (Optional)

The main alternative solution was to continue using Parser.htmlToText and Parser.replace(description). However, this approach did not fully address the markdown formatting needs. Using HTMLElementModel.fromCustomModel allows for more flexible and precise handling of the content and ensures markdown and styling are correctly applied.

Copy link

melvin-bot bot commented Mar 13, 2025

📣 @yaqoob2ishaq4! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@yaqoob2ishaq4
Copy link

Contributor details
Your Expensify account email: Yaqoob.ishaq@dedev.co
Upwork Profile Link: https://www.upwork.com/freelancers/~01b073ac71709078a5?mp_source=share

Copy link

melvin-bot bot commented Mar 13, 2025

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Mar 13, 2025
@mountiny
Copy link
Contributor

@Beamanator feel free to reassign to me if you want to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants