Skip to content

Expense - "Rate is only valid until..." error shown inside report but not on expense preview #95109

Closed

Description

@applause-bot

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.4.26-0
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #93555
Email or phone of affected tester (no customers): applausetester+ib0024@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome
App Component: Money Requests

Action Performed:

Prerequisite: Use an expensifail account.
Prerequisite 2: User is owner of a workspace with "Distance Rates" enabled.
Prerequisite 3: Two custom rates created. Rate A, only has a start date (Jan 1, 2025) and Rate B, only has an end date (Dec 31, 2026)

  1. Open the staging.new.expensify.com website.
  2. Navigate to workspace chat.
  3. Start creating a map distance expense with date on December 2024.
  4. After date is selected, change rate to "Rate A"
  5. Note that a "Rate is only valid from Jan 1, 2025" error appears.
  6. Create expense.
  7. Note that the same error is visible on expense preview and is still visible when opening expense.
  8. Delete the expense.
  9. Start creating a new map distance expense with any date on 2027.
  10. Manually select "Rate B"
  11. Note that a "Rate is only valid until Dec 31, 2025" error appears.
  12. Create the expense.
  13. Note that preview shows "Review Required" instead of showing the same error.
  14. Open the expense.
  15. Note that "Rate is only valid until..." error is displayed on report.

Expected Result:

Error displayed inside report after selecting an expired rate, should be also visible on report preview.

Actual Result:

"Rate only valid until..." error is displayed on report, but only "Review Required" error is displayed on preview instead of the same message being visible.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7196961_1782940620397.Invalid_5.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7196961

Activity

  1. applause-bot commented on Jul 2, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/5e9f23ac940adf35af17ce94aae72797941860696d75128c1126d2d9da63ffb2

  2. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 2, 2026
  3. melvin-bot commented on Jul 2, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #93555

  4. melvin-bot commented on Jul 2, 2026

    @melvin-bot

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

  5. github-actions commented on Jul 2, 2026

    @github-actions
    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.
  6. MelvinBot commented on Jul 2, 2026

    @MelvinBot
    Contributor

    Proposal

    Problem

    The out-of-date-range rate error shows correctly inside the opened expense/report, but the transaction preview falls back to the generic "Review Required" for a rate that only has an end date — while a rate with only a start date shows the specific message just fine. Introduced by #93555 (deploy blocker).

    Root Cause

    The preview truncates any single rate-date warning whose translated text is longer than 40 characters. It's a message-length threshold bug, not a violation-count or wrong-data bug.

    In getViolationTranslatePath, the preview returns violations.reviewRequired whenever violationMessage.length > CONST.REPORT_VIOLATIONS.RBR_MESSAGE_MAX_CHARACTERS_FOR_PREVIEW, which is 40. Both cases have exactly one violation (the customUnitRateOutOfDateRange warning), so the only differing term is message length — and the two variants land on opposite sides of 40:

    • Start-only: Rate is only valid from January 1, 2025 → 39 chars ≤ 40 → shows the message ✅
    • End-only: Rate is only valid until December 31, 2026 → 42 chars > 40 → collapses to "Review Required" ❌

    The opened report doesn't apply this preview-only length gate, which is why the specific message appears there in both cases. (The "Dec 31, 2025" in the report is a reporter transcription artifact — dates render with full month names via MONTH_DAY_YEAR_FORMAT; there's no off-by-one in the code.)

    Changes

    Exempt the single rate-date warning from the length-based truncation in getViolationTranslatePath. The violationMessage.length > 40 term exists to shorten multi-violation summaries — a single legitimate warning shouldn't be collapsed. Gate the length term on there being more than one violation, e.g.:

    const isTooLong =
        violationsCount > 1 ||
        tagViolationsCount > 1 ||
        (violationsCount > 1 && violationMessage.length > CONST.REPORT_VIOLATIONS.RBR_MESSAGE_MAX_CHARACTERS_FOR_PREVIEW);

    Or, more targeted: if the sole filtered violation is customUnitRateOutOfDateRange, return {text: violationMessage} directly. This makes the preview match the opened-report behavior for both start-only and end-only rates.

    Do not just bump RBR_MESSAGE_MAX_CHARACTERS_FOR_PREVIEW — that affects every preview and doesn't fix the underlying "a single valid warning gets truncated" class of bug.

    Investigation details & evidence (SHA 435a62d)
    • Preview message source: TransactionPreviewContent.tsx:135 — violationMessage is the translation of firstViolation = filterReceiptViolations(violations).at(0). For a workspace (group policy), shouldShowOnlyViolations = !isGroupPolicy = false, so filteredViolations = all violations after receipt filtering.
    • Only one violation in both cases: an out-of-range distance expense carries just the customUnitRateOutOfDateRange warning, so violationsCount = 1 and firstViolation is the rate warning in both cases — ordering is not a factor. violationsCount > 1 is false; hasMissingSmartscanFields is false for a distance expense with a valid rate. The only differentiator is the 39-vs-42 length crossing the 40 boundary.
    • Message strings: customUnitRateOutOfDateRangeStartOnly = Rate is only valid from ${startDate}, customUnitRateOutOfDateRangeEndOnly = Rate is only valid until ${endDate} — "until" plus a long end date ("December 31") pushes past 40.
    • Date formatting: formatViolationDate uses MONTH_DAY_YEAR_FORMAT (MMMM d, yyyy) → full month names; the violation data copies mileageRate.startDate/endDate verbatim with no arithmetic, so there's no year off-by-one or field swap.

    Confidence: High — root cause is deterministic from code + string lengths; every claim backed by code read at the merged SHA.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/95109) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  7. removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Jul 2, 2026
  8. rlinoz commented on Jul 2, 2026

    @rlinoz
    Contributor

    Yeah, as melvin explained, this is happening because the two messages have different lengths so that is expected and working as intended.

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

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringHourlyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions