Skip to content

[$125] Rules - "workspace rules" link shows html tags when copied from applied rule system message #82694

Closed

Description

@jponikarchuk

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.3.20-5
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #80853
Email or phone of affected tester (no customers): sdjoisjndoisnjodsoijo@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Rules are enabled.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Rules.
  3. Click Add merchant rule.
  4. Create a rule which applies when Apple is merchant, Merchant will update to Banana.
  5. Go to workspace chat.
  6. Create an expense with Apple as merchant.
  7. Open the expense report.
  8. Right click on "set the merchant to..." system message > Copy to clipboard.
  9. Paste the content.

Expected Result:

"workspace rules" link will not show html tags.

Actual Result:

"workspace rules" link shows html tags when copied from applied rule system message.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @eVoloshchak
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022033944059526830680
  • Upwork Job ID: 2033944059526830680
  • Last Price Increase: 2026-03-17

Activity

  1. etCoderDysto commented on Feb 17, 2026

    @etCoderDysto
    Contributor

    Proposal

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

    "workspace rules" link shows html tags when copied from applied rule system message

    What is the root cause of that problem?

    iou.policyRulesModifiedFields.format key wraps the link in anchor tag

    return translate('iou.policyRulesModifiedFields.format', formatList(fragments), route);

    But when we copy the html we are using Clipboard.setString. And Clipboard.setString, doesn't convert html content to markdown.
    } else if (isModifiedExpenseAction(reportAction)) {
    const modifyExpenseMessage = getForReportActionTemp({
    translate,
    reportAction,
    policy,
    movedFromReport,
    movedToReport,
    policyTags,
    currentUserLogin: currentUserPersonalDetails?.email ?? '',
    });
    Clipboard.setString(modifyExpenseMessage);

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

    We should use setClipboardMessage to copy the message to clipboard as it converts html to markdonw

    setClipboardMessage(modifyExpenseMessage);
    

    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.

  2. annaweber830 commented on Feb 17, 2026

    @annaweber830
    Contributor

    Proposal

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

    When users copy the applied merchant-rule system message from a modified expense action, the pasted text includes raw HTML tags for the "workspace rules" link instead of clean readable text.

    What is the root cause of that problem?

    The modified-expense copy branch writes the message to clipboard with Clipboard.setString() directly, even though the message can contain HTML.

    } else if (isModifiedExpenseAction(reportAction)) {
    const modifyExpenseMessage = getForReportActionTemp({
    translate,
    reportAction,
    policy,
    movedFromReport,
    movedToReport,
    policyTags,
    currentUserLogin: currentUserPersonalDetails?.email ?? '',
    });
    Clipboard.setString(modifyExpenseMessage);

    } else if (isModifiedExpenseAction(reportAction)) {
        const modifyExpenseMessage = getForReportActionTemp({
            translate,
            reportAction,
            policy,
            movedFromReport,
            movedToReport,
            policyTags,
            currentUserLogin: currentUserPersonalDetails?.email ?? '',
        });
        Clipboard.setString(modifyExpenseMessage);
    }

    That message can include an anchor tag by design (via <a href="...">workspace rules</a>), so copying it as plain string preserves HTML markup. This causes pasted content to show raw <a ...> tags because no HTML-to-markdown conversion is applied in this branch.

    App/src/languages/en.ts

    Lines 1553 to 1558 in d3c00a5

    common: (key: keyof PolicyRulesModifiedFields, value: string, isFirst: boolean) => {
    const field = translations.common[key].toLowerCase();
    return isFirst ? `set the ${field} to "${value}"` : `${field} to "${value}"`;
    },
    format: (fragments: string, route: string) => `${fragments} via <a href="${route}">workspace rules</a>`,
    },

    common: (key: keyof PolicyRulesModifiedFields, value: string, isFirst: boolean) => {
        const field = translations.common[key].toLowerCase();
        return isFirst ? `set the ${field} to "${value}"` : `${field} to "${value}"`;
    },
    format: (fragments: string, route: string) => `${fragments} via <a href="${route}">workspace rules</a>`,

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

    Use setClipboardMessage(modifyExpenseMessage) in the modified-expense branch so HTML messages are converted to markdown/plain text consistently with the rest of the context menu copy handlers.

    } else if (isModifiedExpenseAction(reportAction)) {
    const modifyExpenseMessage = getForReportActionTemp({
    translate,
    reportAction,
    policy,
    movedFromReport,
    movedToReport,
    policyTags,
    currentUserLogin: currentUserPersonalDetails?.email ?? '',
    });
    Clipboard.setString(modifyExpenseMessage);

    Current code:

    } else if (isModifiedExpenseAction(reportAction)) {
        const modifyExpenseMessage = getForReportActionTemp({
            translate,
            reportAction,
            policy,
            movedFromReport,
            movedToReport,
            policyTags,
            currentUserLogin: currentUserPersonalDetails?.email ?? '',
        });
        Clipboard.setString(modifyExpenseMessage);
    }

    Updated code:

    } else if (isModifiedExpenseAction(reportAction)) {
        const modifyExpenseMessage = getForReportActionTemp({
            translate,
            reportAction,
            policy,
            movedFromReport,
            movedToReport,
            policyTags,
            currentUserLogin: currentUserPersonalDetails?.email ?? '',
        });
        setClipboardMessage(modifyExpenseMessage);
    }

    This keeps behavior aligned with other HTML-capable report actions already using setClipboardMessage(), and ensures plain-text paste does not expose raw HTML tags.

    What alternative solutions did you explore? (Optional)

    1. Add a local HTML check (displayMessage === Parser.htmlToText(displayMessage)) before deciding clipboard method in this branch.
    2. Rejected because setClipboardMessage() already centralizes the conversion logic and keeps copy handling consistent with similar branches.
  3. melvin-bot commented on Feb 23, 2026

    @melvin-bot

    Huh... This is 4 days overdue. Who can take care of this?

  4. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    This issue has not been updated in over 14 days. eroding to Weekly issue.

  5. self-assigned this
    on Mar 17, 2026
  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 17, 2026
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 17, 2026
  8. 1 remaining item

  9. melvin-bot commented on Mar 17, 2026

    @melvin-bot

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

  10. changed the title [-]Rules - "workspace rules" link shows html tags when copied from applied rule system message[/-] [+][$250] Rules - "workspace rules" link shows html tags when copied from applied rule system message[/+] on Mar 17, 2026
  11. melvin-bot commented on Mar 17, 2026

    @melvin-bot
  12. changed the title [-][$250] Rules - "workspace rules" link shows html tags when copied from applied rule system message[/-] [+][$125] Rules - "workspace rules" link shows html tags when copied from applied rule system message[/+] on Mar 17, 2026
  13. melvin-bot commented on Mar 17, 2026

    @melvin-bot

    Upwork job price has been updated to $125

  14. mukhrr commented on Mar 17, 2026

    @mukhrr
    Contributor

    Proposal

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

    When a workspace merchant rule is applied to an expense (e.g., "set the merchant to Banana"), right-clicking the system message and selecting "Copy to clipboard" copies the raw HTML <a> tags for the "workspace rules" link, causing the pasted text to show something like via <a href="...">workspace rules</a> instead of clean, readable text.

    What is the root cause of that problem?

    When copying a modified expense message that was triggered by policy rules, the code uses Clipboard.setString() directly with the message returned by getForReportActionTemp(). This message contains HTML anchor tags (e.g., <a href="...">workspace rules</a>) because it is intended to be rendered as HTML in the chat. However, Clipboard.setString() copies the string as-is without stripping or converting the HTML, so the raw tags end up in the clipboard.
    https://github.com/Expensify/App/blob/eb0e71a21cb7c337ead8c37cd47140cae68fd8ca/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx#L779-L789

    Other report action types that contain HTML (e.g., task actions at line 778, member change actions at line 806) correctly use the setClipboardMessage() helper, which converts HTML to markdown for the plain text clipboard and preserves HTML for rich text. The modified expense action branch is the only one that bypasses this.
    https://github.com/Expensify/App/blob/eb0e71a21cb7c337ead8c37cd47140cae68fd8ca/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx#L211-L223

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

    1. In ContextMenuActions.tsx, change the modified expense action copy handler to use setClipboardMessage() if it's html markdown, so the HTML content is properly converted to markdown for the plain text clipboard.
      https://github.com/Expensify/App/blob/eb0e71a21cb7c337ead8c37cd47140cae68fd8ca/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx#L789
    --- a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx
    +++ b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx
    @@ -786,7 +786,7 @@
                             policyTags,
                             currentUserLogin: currentUserPersonalDetails?.email ?? '',
                         });
    -                    Clipboard.setString(modifyExpenseMessage);
    +                   if(displayMessage === Parser.htmlToText(displayMessage)){
    +                      Clipboard.setString(modifyExpenseMessage);
    +                   }else {
    +                    setClipboardMessage(modifyExpenseMessage);
    +                   }

    This ensures the "workspace rules" link is converted to a clean markdown link [workspace rules](url) for the plain text clipboard, matching the behavior of other HTML-containing messages.

  15. github-actions commented on Mar 17, 2026

    @github-actions
    Contributor

    ⚠️ @mukhrr Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  16. eVoloshchak commented on Mar 18, 2026

    @eVoloshchak
    Contributor

    @etCoderDysto's proposal looks good to me!

    🎀👀🎀 C+ reviewed!

  17. melvin-bot commented on Mar 18, 2026

    @melvin-bot

    Current assignee @luacmartins is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

  18. situchan commented on Mar 18, 2026

    @situchan
    Contributor

    This is no longer reproducible

    Image
  19. luacmartins commented on Mar 18, 2026

    @luacmartins
    Contributor

    Cool, seems like we can close this then

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

Metadata

Metadata

Labels

DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions