Skip to content

[Due for payment 2026-05-11] [$250] Expense - Unable to reject expense with reason <Shahrukh,khan> and "Try again" error #87047

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.52-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #86622
Email or phone of affected tester (no customers): jsat+2abr@applausemail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Samsung Galaxy S21 Ultra/Android 15/Chrome, Macbook Pro/macOS 13.7.8/Chrome
App Component: Other

Action Performed:

Launch Expensify App
Log in with valid credentials
Create a workspace
Create manual expense
Submit the expense
Reject the expense with reason <Shahrukh,khan>
Tap save

Expected Result:

The expense is rejected successfully and rejection reason is displayed properly.

Actual Result:

The expense is not rejected and rejection reason is not displayed properly

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Video.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022039927148940725565
  • Upwork Job ID: 2039927148940725565
  • Last Price Increase: 2026-04-10
  • Automatic offers:
    • linhvovan29546 | Contributor | 111123086

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 3, 2026
  2. MelvinBot commented on Apr 3, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The report-level reject flow (rejectExpenseReport) sends the raw, unescaped comment to both the API and the optimistic report action. When the rejection reason contains angle brackets like <Shahrukh,khan>, the backend interprets it as an HTML tag and strips it (or rejects the request), causing the "Try again" error.

    The transaction-level reject flow (prepareRejectMoneyRequestData) handles this correctly by calling getParsedComment(comment) which escapes < to &lt; and > to &gt; before sending to the API (IOU/index.ts:12242, IOU/index.ts:12924). The optimistic action builder for this flow also correctly uses getParsedComment for the html field (ReportUtils.ts:13104).

    The report-level flow skips this escaping:

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

    1. In rejectExpenseReport (IOU/index.ts), pass the comment through getParsedComment(comment) before sending it in the API parameters — matching the pattern at line 12924.

    2. In buildOptimisticReportLevelRejectCommentAction (ReportUtils.ts:13177), change html: comment to html: getParsedComment(comment) — matching the pattern at line 13104.

    What alternative solutions did you explore? (Optional)

    Sanitizing at the form input level was considered but rejected — the escaping should happen at the API/rendering boundary, consistent with how the transaction-level flow already works. The correct pattern already exists in the codebase; it just needs to be applied consistently.

    Evidence

    Correct pattern (transaction-level reject):

    • IOU/index.ts:12242: const parsedComment = getParsedComment(comment);
    • IOU/index.ts:12924: comment: parsedComment (in API params)
    • ReportUtils.ts:13104: html: getParsedComment(comment) (in optimistic action)

    Buggy pattern (report-level reject):

    • IOU/index.ts:13964: comment, (raw, unescaped in API params)
    • ReportUtils.ts:13177: html: comment, (raw, unescaped in optimistic action)

    getParsedComment calls Parser.replace with shouldEscapeText: true, which converts < to &lt; and > to &gt; via escapeText() in expensify-common.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 3, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 3, 2026
  5. melvin-bot commented on Apr 3, 2026

    @melvin-bot

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

  6. melvin-bot commented on Apr 3, 2026

    @melvin-bot
  7. changed the title [-]Expense - Unable to reject expense with reason <Shahrukh,khan> and "Try again" error[/-] [+][$250] Expense - Unable to reject expense with reason <Shahrukh,khan> and "Try again" error[/+] on Apr 3, 2026
  8. trasnake87 commented on Apr 3, 2026

    @trasnake87
    Contributor

    Proposal

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

    When rejecting an expense report with a reason containing angle brackets (e.g. <Shahrukh,khan>), the rejection fails with a "Try again" error because the raw text is interpreted as HTML markup.

    What is the root cause of that problem?

    The RejectExpenseReportPage component at src/pages/RejectExpenseReportPage.tsx#L145-L148 passes the raw form value directly to rejectExpenseReport without first parsing/escaping the comment. Other form pages that accept free-text comments (e.g. TaskTitlePage, WorkspaceNewRoomPage, SplitExpenseEditPage) all call getParsedComment before passing user input downstream. The transaction-level rejection page (RejectReasonPage) doesn't have this issue because its downstream action (prepareRejectMoneyRequestData) calls getParsedComment internally — but the report-level path has no escaping at any layer.

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

    We should parse the comment in RejectExpenseReportPage.tsx before passing it to the action, consistent with how other form pages handle user text input. This is a single-file fix:

    // src/pages/RejectExpenseReportPage.tsx
    
    // Add to imports:
    import {getParsedComment} from '@libs/ReportUtils';
    
    // In onSubmit, parse the comment before passing it:
    const onSubmit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.REPORT_REJECT_FORM>) => {
        // ... delegate check ...
        const targetAccountID = hasPreviousApprover ? Number(selectedTargetAccountID) : submitterAccountID;
        if (!report) {
            return;
        }
        const parsedComment = getParsedComment(values[INPUT_IDS.COMMENT]);
        rejectExpenseReport(
            report,
            targetAccountID,
            parsedComment,
            currentUserPersonalDetails?.accountID,
            currentUserPersonalDetails?.displayName,
            currentUserPersonalDetails?.avatar,
        );
        Navigation.goBack();
    };

    This ensures angle brackets and other special characters are properly escaped to their HTML entities before reaching the API, matching the pattern used by TaskTitlePage, WorkspaceNewRoomPage, and SplitExpenseEditPage.

  9. trasnake87 commented on Apr 3, 2026

    @trasnake87
    Contributor

    Contributor details
    Your Expensify account email: trasnake87@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~010f770315ab181656

  10. melvin-bot commented on Apr 3, 2026

    @melvin-bot

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

  11. wildan-m commented on Apr 3, 2026

    @wildan-m
    Contributor

    Proposal

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

    When rejecting an expense report with a reason containing angle brackets (e.g. <Shahrukh,khan>), the rejection fails with a "Try again" error and the reason is not displayed properly, because the raw text is interpreted as HTML markup.

    What is the root cause of that problem?

    The report-level reject flow sends the raw, unescaped comment to both the API and the optimistic report action. The transaction-level reject flow handles this correctly — it calls getParsedComment(comment) before sending to the API, and buildOptimisticRejectReportActionComment uses getParsedComment(comment) for the html field while keeping raw comment for the text field:

    const parsedComment = getParsedComment(comment);

    App/src/libs/ReportUtils.ts

    Lines 13100 to 13105 in c530e02

    message: [
    {
    type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
    text: comment,
    html: getParsedComment(comment),
    },

    The report-level reject flow skips this escaping in two places:

    1. rejectExpenseReport sends raw comment to the API parameters — the backend interprets <Shahrukh,khan> as an HTML tag and rejects the request:

    App/src/libs/actions/IOU/index.ts

    Lines 13961 to 13967 in c530e02

    const parameters: RejectExpenseReportParams = {
    reportID,
    targetAccountID,
    comment,
    rejectedActionReportActionID: optimisticRejectAction.reportActionID,
    rejectedCommentReportActionID: optimisticCommentAction.reportActionID,
    };

    1. buildOptimisticReportLevelRejectCommentAction uses raw comment for the html field in the optimistic action message — the text field correctly stays as raw text, but html must be escaped:

    App/src/libs/ReportUtils.ts

    Lines 13173 to 13178 in c530e02

    message: [
    {
    type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
    text: comment,
    html: comment,
    },

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

    Fix at the action layer to match the existing transaction-level pattern:

    1. In rejectExpenseReport (IOU/index.ts), pass the comment through getParsedComment(comment) in the API parameters — matching line 12924 where the transaction-level flow does the same.

    2. In buildOptimisticReportLevelRejectCommentAction (ReportUtils.ts), change html: comment to html: getParsedComment(comment) — matching line 13104 where buildOptimisticRejectReportActionComment does the same. The text field must remain as the raw comment (plain text), while only html gets the parsed/escaped version.

    This is important because the message object has two distinct fields: text (plain text for fallback/search) and html (HTML for rendering). Escaping must happen at this boundary to preserve both correctly.

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/87047-fix-reject-comment-escaping?expand=1

    What alternative solutions did you explore? (Optional)

    Escaping at the page/form level (in RejectExpenseReportPage.tsx) was considered but rejected because it would pass the already-escaped HTML string as the comment parameter to rejectExpenseReport, which then flows into buildOptimisticReportLevelRejectCommentAction as the text field. This would corrupt the text field with HTML entities (e.g. &lt;Shahrukh,khan&gt; instead of <Shahrukh,khan>), breaking plain-text display and search. The correct pattern — used by the analogous transaction-level flow — is to escape inside the action/builder functions where text and html diverge.

  12. wildan-m commented on Apr 3, 2026

    @wildan-m
    Contributor

    Proposal

    Updated

    Added compare branch with implementation.

  13. 61 remaining items

  14. changed the title [-][$250] Expense - Unable to reject expense with reason <Shahrukh,khan> and "Try again" error[/-] [+][Due for payment 2026-05-11] [$250] Expense - Unable to reject expense with reason <Shahrukh,khan> and "Try again" error[/+] on May 4, 2026
  15. melvin-bot commented on May 4, 2026

    @melvin-bot

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

  16. melvin-bot commented on May 4, 2026

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.65-6 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 2026-05-11. 🎊

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

  17. melvin-bot commented on May 4, 2026

    @melvin-bot

    @linhvovan29546 / @truph01 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]

  18. melvin-bot commented on May 7, 2026

    @melvin-bot

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

  19. melvin-bot commented on May 10, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  20. linhvovan29546 commented on May 11, 2026

    @linhvovan29546
    Contributor

    BugZero 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: N/A — this is an edge case that’s part of the reject report project.
      Link to the comment on the Issue: N/A — this is an edge case that’s part of the reject report project.

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

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Test:

    N/A — we already have a regression test for this https://github.com/Expensify/Expensify/issues/625221

    Do we agree 👍 or 👎

  21. mallenexpensify commented on May 11, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @linhvovan29546 paid $250 via Upwork
    Contributor+: @truph01 due $250 via NewDot

    Thx!

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.DailyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions