Skip to content

fix: description with url is shown as text in preview#83422

Open
daledah wants to merge 16 commits intoExpensify:mainfrom
daledah:fix/82301
Open

fix: description with url is shown as text in preview#83422
daledah wants to merge 16 commits intoExpensify:mainfrom
daledah:fix/82301

Conversation

@daledah
Copy link
Contributor

@daledah daledah commented Feb 25, 2026

Explanation of Change

Fixed Issues

$ #82301
PROPOSAL: #82301 (comment)

Tests

Test case 1

  1. Launch the Expensify app
  2. Open the self DM section.
  3. Create a new expense with a description that includes a URL (e.g., #google.com).
  4. Observe the preview of the expense
  5. Verify that: In the self DM section, the description with a URL should be displayed as a clickable link and truncated to 1 line.

Test case 2

  1. Launch the Expensify app
  2. Open the self DM section.
  3. Create a new expense with a normal description (e.g., this is the description)
  4. Observe the preview of the expense
  5. Verify that: In the self DM section, the description should be displayed as normal text and truncated to 1 line.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native android
Android: mWeb Chrome android
iOS: Native ios
iOS: mWeb Safari ios-mweb
MacOS: Chrome / Safari web

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/RenderHTML.tsx 100.00% <100.00%> (ø)
...m/TransactionPreview/TransactionPreviewContent.tsx 78.21% <100.00%> (+0.89%) ⬆️
... and 21 files with indirect coverage changes

@daledah daledah marked this pull request as ready for review February 27, 2026 05:44
@daledah daledah requested review from a team as code owners February 27, 2026 05:44
@melvin-bot melvin-bot bot requested review from DylanDylann and removed request for a team February 27, 2026 05:44
@melvin-bot
Copy link

melvin-bot bot commented Feb 27, 2026

@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot requested review from JmillsExpensify and removed request for a team February 27, 2026 05:44
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6241a5ce28

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link
Contributor

@JmillsExpensify JmillsExpensify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good for product.

@DylanDylann
Copy link
Contributor

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

@DylanDylann
Copy link
Contributor

@daledah please resolve all the above comments from codex and github-actions

@daledah
Copy link
Contributor Author

daledah commented Mar 3, 2026

@DylanDylann looks like we allow the Multi-Line row wrapping in Expense Previews in this PR so i updated my solution to match with this expected. Please check again

@daledah
Copy link
Contributor Author

daledah commented Mar 5, 2026

@DylanDylann looks like we allow the Multi-Line row wrapping in Expense Previews in this #82967 so i updated my solution to match with this expected. Please check again

looks like the PR is reverted, i updated to previous version

@DylanDylann
Copy link
Contributor

@daledah Is this ready?

@daledah
Copy link
Contributor Author

daledah commented Mar 5, 2026

@DylanDylann yes, i updated. Please move forward

@DylanDylann
Copy link
Contributor

@daledah Please check the failed test

@DylanDylann
Copy link
Contributor

@daledah

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

@DylanDylann
Copy link
Contributor

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de99380163

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@DylanDylann
Copy link
Contributor

@daledah Is this expected to handle the truncation in 2 lines?

@daledah Since the width of the transaction preview can change, I'm not sure we should use a fixed max character limit. For normal descriptions, the text auto-truncates when there's not enough space. Could you check if we can do the same with HTML rendering? Otherwise, I think we need to confirm this new behavior with the design team first.

@DylanDylann
Copy link
Contributor

We only made minor UI changes in the transaction preview section and did not add any new hooks or utility functions, so there are no new logic paths that require test coverage here

From https://github.com/Expensify/App/blob/main/contributingGuides/CodeCov.md

If a file has existing coverage, we should always be trying to increase or maintain the existing level of coverage. That way, over time, our code coverage will increase, we will catch more bugs in the PR-stage, and fewer PRs will have to be reverted. Decreasing coverage for a file should be avoided!

TransactionPreviewContent is already covered (likely nested in a parent component), so I think we should maintain the coverage of this file. For an easier approach, we can create a new test for TransactionPreviewContent. Wdyt?

@DylanDylann
Copy link
Contributor

@daledah This is my draft try, I believe it will help us in this case to maintain code coverage

TransactionPreviewContent.test.tsx

@daledah
Copy link
Contributor Author

daledah commented Mar 10, 2026

@daledah Could you update test step to allow test on all platform and cover the truncation case?

i updated

@daledah Is this expected to handle the truncation in 2 lines?

I’m not sure what the expected behavior is here—whether it should be one line or two lines. We previously had a PR that allowed multi-line row wrapping in Expense Previews, but it was reverted. Could you tag the design team here and ask what the expected behavior should be?

@daledah This is my draft try, I believe it will help us in this case to maintain code coverage

thanks @DylanDylann, I tried your test and it worked. I added

@DylanDylann
Copy link
Contributor

I’m not sure what the expected behavior is here—whether it should be one line or two lines. We previously had a #82967 that allowed multi-line row wrapping in Expense Previews, but it was reverted. Could you tag the design team here and ask what the expected behavior should be?

@daledah It looks like another screen. Could you please ask the author of that PR to confirm?

@daledah
Copy link
Contributor Author

daledah commented Mar 14, 2026

I’m not sure what the expected behavior is here—whether it should be one line or two lines. We previously had a #82967 that allowed multi-line row wrapping in Expense Previews, but it was reverted. Could you tag the design team here and ask what the expected behavior should be?

@TaduJR could you please confirm that we should show the description and the merchant on two lines, as implemented in this PR?

@TaduJR
Copy link
Contributor

TaduJR commented Mar 14, 2026

@TaduJR could you please confirm that we should show the description and the merchant on two lines, as implemented in this #82967?

@daledah

No we should not show two line for Expense Preview, two line feature is only intended for Reports Page view.

For more context please check out this thread https://expensify.slack.com/archives/C01GTK53T8Q/p1772543905741479

LMK if you need anything else.

Thanks!

@daledah
Copy link
Contributor Author

daledah commented Mar 16, 2026

No we should not show two line for Expense Preview, two line feature is only intended for Reports Page view.

thanks @TaduJR

@daledah
Copy link
Contributor Author

daledah commented Mar 16, 2026

@DylanDylann i updated, please check again

@DylanDylann
Copy link
Contributor

@daledah Since the width of the transaction preview can change, I'm not sure we should use a fixed max character limit. For normal descriptions, the text auto-truncates when there's not enough space. Could you check if we can do the same with HTML rendering? Otherwise, I think we need to confirm this new behavior with the design team first.

@daledah With the current approach, we would change the original behavior. We shouldn’t hard-code the max length because the available space may vary depending on the screen.

@daledah
Copy link
Contributor Author

daledah commented Mar 17, 2026

@daledah With the current approach, we would change the original behavior. We shouldn’t hard-code the max length because the available space may vary depending on the screen.

@DylanDylann I've updated. Please check again

@daledah
Copy link
Contributor Author

daledah commented Mar 17, 2026

Looks like the failing check is not related to this PR. i'll merge main to resolve it soon


const description = truncate(StringUtils.lineBreaksToSpaces(Parser.htmlToText(requestComment ?? '')), {length: CONST.REQUEST_PREVIEW.MAX_LENGTH});
const isDescriptionHTML = !!requestComment && Parser.isHTML(requestComment);
const requestDescription = truncate(requestComment ?? '', {length: CONST.REQUEST_PREVIEW.MAX_LENGTH});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MelvinBot Could you check whether removing lineBreaksToSpaces is safe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DylanDylann
Copy link
Contributor

@codex review

@MelvinBot
Copy link
Contributor

Removing lineBreaksToSpaces is mostly safe for the common case but introduces edge-case risks worth being aware of:

Why it was there (old flow)

requestComment → Parser.htmlToText() [strips ALL tags, converts <br> to \n]
  → lineBreaksToSpaces() [converts \n to space]
  → truncate()
  → <Text numberOfLines={1}> = guaranteed flat single line

New flow

requestComment → Parser.truncateHTML() or truncate() [preserves HTML structure]
  → <RenderHTML numberOfLines={1} />

What's safe

  • Inline HTML (<br>, <strong>, <em>, <a>): react-native-render-html renders <br> as '\n' inside <Text> components, and numberOfLines={1} on defaultTextProps truncates them correctly.
  • Non-HTML text with \n: In HTML rendering context, literal \n is treated as whitespace and collapsed, so single-line behavior is preserved.

Potential risks

  1. Block-level HTML in descriptions — If a description contains <blockquote>, <p>, <div>, or <h1>, react-native-render-html renders these as <View> components, which ignore numberOfLines entirely. Parser.truncateHTML() preserves these tags, so they'd render as multi-block layout instead of a single line. (Risk level depends on whether transaction descriptions can actually contain block-level elements in practice.)

  2. Custom renderer loss — When numberOfLines is passed, RenderHTML.tsx creates its own RenderHTMLConfigProvider with only BulletItemRenderer and SparklesIconRenderer. The full set of custom renderers from HTMLEngineProvider (anchors with custom press handling, mentions, inline code, etc.) are not available. If descriptions contain <a> tags (which is the whole point of this PR), the links would render with default behavior rather than Expensify's custom anchor renderer. This could affect link press behavior and styling.

  3. Minor: The wrapping <View style={styles.renderHTML}> includes whiteSpace: preWrap, which preserves whitespace/line breaks at the container level — though numberOfLines={1} on the inner <Text> should override this visually.

Summary

The removal is safe if transaction descriptions only contain inline HTML (which appears to be the common case). The main concern is risk #2 — losing custom renderers may affect how links behave/look in the preview. It would be worth verifying that link press handling and styling work as expected with the limited renderer set.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fb2e6ff22

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +72 to +75
<RenderHTMLConfigProvider
defaultTextProps={{selectable: isSelectable ?? true, allowFontScaling: false, numberOfLines}}
renderersProps={renderersProps}
renderers={renderers}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve custom HTML renderers in the new truncation path

When numberOfLines is set, this wraps the source in a fresh RenderHTMLConfigProvider that only registers bullet-item and sparkles-icon. I checked react-native-render-html's RenderHTMLConfigProvider/RenderRegistryProvider for v6.3.1, and nested providers rebuild the renderer registry from the passed renderers instead of merging the ambient one. That means transaction previews rendered via numberOfLines no longer use our a, deleted-action, mention-*, etc. renderers from BaseHTMLEngineProvider, so links in descriptions will bypass AnchorRenderer's internal-link/deleted-state handling.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MelvinBot Could you explain the comment above in more detail?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Codex comment is about a custom renderer loss issue. Here's the detailed explanation:

How HTML rendering works in the App

The app has a global BaseHTMLEngineProvider (BaseHTMLEngineProvider.tsx:251) that registers 22 custom renderers for tags like <a>, <code>, <img>, <mention-user>, <deleted-action>, etc. These custom renderers handle Expensify-specific behavior — for example, AnchorRenderer handles internal link navigation, hover styles, deleted-state strikethrough on links, and right-click context menus.

What happens when numberOfLines is passed

In RenderHTML.tsx:67-78, when numberOfLines is set, the component creates a new nested RenderHTMLConfigProvider:

if (onLinkPress !== undefined || numberOfLines !== undefined) {
    return (
        <RenderHTMLConfigProvider
            defaultTextProps={{selectable: isSelectable ?? true, allowFontScaling: false, numberOfLines}}
            renderersProps={renderersProps}
            renderers={renderers}  // ← only has bullet-item and sparkles-icon!
        >
            {htmlSource}
        </RenderHTMLConfigProvider>
    );
}

The renderers object (RenderHTML.tsx:57-61) only includes 2 of the 22 custom renderers:

  • bullet-item
  • sparkles-icon

Why inner providers replace rather than merge

react-native-render-html's RenderHTMLConfigProvider creates a new RenderRegistryProvider that sets a fresh context value. In React, the innermost context provider wins — it doesn't merge with the outer one. So the inner provider with 2 renderers completely shadows the outer BaseHTMLEngineProvider that has all 22.

What's lost (20 renderers)

a (AnchorRenderer), code, img, video, edited, pre, task-title, rbr, mention-user, mention-report, mention-here, mention-short, user-details, copy-text, emoji, next-step-email, deleted-action, concierge-link, transaction-history-link, account-manager-link

Why this matters for the PR

The most critical loss is AnchorRenderer (a tag). The whole point of this PR is to make URL descriptions clickable in transaction previews. Without the custom AnchorRenderer, links will still render (the library has a built-in default <a> handler), but they'll lose:

  1. Internal link navigation — Expensify URLs won't use openLink for in-app navigation
  2. Deleted-state styling — strikethrough won't apply to links inside deleted actions
  3. Context menu — no right-click menu via AnchorForCommentsOnly
  4. Hover styles — no custom hover behavior

Note: this is a pre-existing issue

The same 2-renderer limitation existed before this PR for the onLinkPress code path. This PR just expanded the trigger to also include numberOfLines, exposing it in a new context where <a> tags matter.

Possible fix

The RenderHTML component should either:

  • Import and spread htmlRenderers from HTMLEngineProvider/HTMLRenderers into its local renderers object
  • Or read the current renderers from context and merge with local overrides
  • Or avoid creating a separate RenderHTMLConfigProvider and pass numberOfLines through a different mechanism

Comment on lines +344 to +346
<RenderHTML
html={isDeleted ? `<del>${description}</del>` : description}
numberOfLines={1}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep non-HTML descriptions on the plain Text path

isDescriptionHTML is computed here, but the new render branch ignores it and sends every description through <RenderHTML>. For expense descriptions that are just arbitrary user input, strings containing literal tag-like text such as <draft> or 5 < 10 can now be interpreted as markup instead of being shown verbatim, whereas the previous <Text> path displayed the raw text. This only affects previews without a merchant, but it is a user-visible regression for plain descriptions that merely happen to contain angle brackets.

Useful? React with 👍 / 👎.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. @daledah Could you check this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DylanDylann i updated

@DylanDylann
Copy link
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
Screen.Recording.2026-03-18.at.14.32.50.mov
iOS: HybridApp
Screen.Recording.2026-03-18.at.14.34.27.mov
iOS: mWeb Safari
Screen.Recording.2026-03-18.at.14.32.25.mov
MacOS: Chrome / Safari
Screen.Recording.2026-03-18.at.14.30.53.mov

@DylanDylann
Copy link
Contributor

@daledah It doesn't work on Android

Screenshot 2026-03-18 at 14 43 59

@daledah
Copy link
Contributor Author

daledah commented Mar 24, 2026

still find the solution for the android bug here

Comment on lines +344 to +346
<RenderHTML
html={isDeleted ? `<del>${description}</del>` : description}
numberOfLines={1}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MelvinBot Could you investigate why the truncated logic doesn't work on the Android app?

@MelvinBot
Copy link
Contributor

🔍 Investigation: Why truncation doesn't work on Android

Summary: The numberOfLines={1} prop passed via defaultTextProps in react-native-render-html gets applied to every <Text> node in the tree (both parent and children), not just the outermost one. Android's text layout engine handles this differently from iOS.

Root Cause: When RenderHTML passes numberOfLines through defaultTextProps in the RenderHTMLConfigProvider, the library's internal getNativePropsForTNode helper spreads textProps (including numberOfLines) into every text-type TNode's native props. For HTML like text <a href="...">link</a>, this produces:

<Text numberOfLines={1}>        ← anonymous TPhrasing wrapper
  <Text numberOfLines={1}>text </Text>    ← TText child
  <Text numberOfLines={1}>link</Text>     ← TText child (anchor)
</Text>

On iOS/Web, the parent <Text numberOfLines={1}> correctly constrains the entire nested content to 1 line — child numberOfLines is effectively ignored because the parent already limits layout.

On Android, React Native's text layout engine does not properly propagate numberOfLines through nested <Text> hierarchies the same way. The duplicate numberOfLines={1} on both parent and children causes incorrect truncation behavior — this is a well-known Android-specific quirk in React Native.

Recommended Fix Options (from simplest to most involved):

  1. Wrap with a single <Text numberOfLines={1}> container — Instead of relying on defaultTextProps, wrap the RenderHTMLSource output in a <Text numberOfLines={1}> and remove numberOfLines from defaultTextProps. This ensures only the outermost text node constrains lines.

  2. Use textFormatting approach — For this specific single-line preview use case, convert HTML to text while preserving enough structure for display, then render in a plain <Text numberOfLines={1}>. This avoids the nested-Text problem entirely.

  3. Platform-specific handling — Apply numberOfLines via defaultTextProps only on iOS/Web, and use a <Text> wrapper approach on Android.

Detailed Investigation

Evidence Chain

  1. RenderHTML.tsx:72-79 — Creates a RenderHTMLConfigProvider with defaultTextProps={{numberOfLines}}. This provider also overrides the outer HTMLEngineProvider's renderer registry, replacing the full set of custom renderers (including AnchorRenderer) with only BulletItemRenderer and SparklesIconRenderer.

  2. react-native-render-html/src/context/SharedPropsProvider.tsx:24-36useDefaultContainerProps() merges defaultTextProps from SharedPropsProvider, making numberOfLines available to every renderer.

  3. react-native-render-html/src/helpers/getNativePropsForTNode.ts:58-74textProps (containing numberOfLines) is spread into the native props of every text-type TNode. There's no mechanism to restrict it to only the root node.

  4. @native-html/transient-render-engine/src/flow/hoist.ts:10-42 — The groupText() function wraps all inline/phrasing children of a block in an anonymous TPhrasing wrapper. This creates the nested <Text> tree structure where every node gets numberOfLines.

  5. TransactionPreviewContent.tsx:343-348 — The callsite wraps RenderHTML in a <View style={[styles.flexShrink1, styles.renderHTML]}>, so the outermost element is a View, not Text.

Additional Note

The inner RenderHTMLConfigProvider also loses the custom AnchorRenderer from HTMLEngineProvider. This means <a> tags fall back to the library's built-in renderer — link press handling and styling may differ from the rest of the app.


Next Steps: @daledah Based on this analysis, the most straightforward fix would be option 1 — wrapping the rendered HTML output in a <Text numberOfLines={1}> instead of (or in addition to) passing numberOfLines through defaultTextProps. This avoids the Android nested-Text quirk entirely.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants