Skip to content

Rules - Edited rule is crossed out after changing category offline #96817

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.43-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #95312
Email or phone of affected tester (no customers): applausetester+ssndjois2jd1@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Log in with Expensifail account.
  • Enable Rules.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Rules > Field requirements.
  3. Click Create field requirement rule.
  4. Select a category.
  5. Select Require for Description, Receipt and Itemized receipt.
  6. Click Save rule.
  7. Go offline.
  8. Open the created rule.
  9. Change category and save it.

Expected Result:

The edited rule will be grayed out after changing category offline.

Actual Result:

The edited rule is crossed out after changing category offline.
A new rule is created instead.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7215055_1784769440686.9.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7215055

Issue OwnerCurrent Issue Owner: @Krishna2323

Activity

  1. added
    DeployBlockerCash
    Bug
    on Jul 23, 2026
  2. applause-bot commented on Jul 23, 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/9d11315cfa9cd1ba717558b0d64330f7bdedd24df182473585d326d8e2bc3108

  3. melvin-bot commented on Jul 23, 2026

    @melvin-bot

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

  4. melvin-bot commented on Jul 23, 2026

    @melvin-bot

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

  5. github-actions commented on Jul 23, 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 23, 2026

    @MelvinBot
    Contributor

    Proposal

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

    When you edit a Field requirements rule offline and change its category, the original rule row is shown crossed out (pending delete) and a new rule appears, instead of the single rule simply being grayed out (pending update).

    What is the root cause of that problem?

    Field-requirement "rules" are not standalone records — they are flags stored directly on the PolicyCategory object, keyed by category name. The rule's identity is its category (RequireFieldsRulesUtils.ts:43-49), so there is no backend "move to another category" op.

    When the category changes, the save handler intentionally does delete-old + create-new (RequireFieldsRulePageBase.tsx:348-352): deleteRequireFieldsRule stamps pendingFields.<field> = DELETE on the old category, which getRequireFieldsPendingActionForCategory collapses into a category-level DELETE (crossed-out row).

    This is invisible online because pending-DELETE rows are filtered out of the table — but that filter is gated on !isOffline, so offline the crossed-out old row stays visible (RequireFieldsRulesUtils.ts:716-721):

    if (!isOffline && isPendingDelete) {
        continue;
    }

    Result: offline you see the original rule crossed out plus the new rule; online you only see the reassigned (grayed) rule.

    Data flow
    1. Edit rule offline, pick a new category → handleSave computes didChangeCategory = true.
    2. deleteRequireFieldsRule(oldCategory) clears every field on the old category, each write stamping pendingFields.<field> = DELETE.
    3. saveRequireFieldsRule(newCategory) stamps the new category's fields with pendingFields = UPDATE.
    4. Table build: old category → DELETE (full delete, crossed out); new category → UPDATE (grayed).
    5. Offline the !isOffline && isPendingDelete guard does not skip the old row, so both render.

    Introduced by #95312 (rewrote RequireFieldsRulesUtils.ts, +717).

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

    The delete+create data operations are unavoidable (the model is per-category), so the fix is display-only: don't show the reassigned old-category row as a crossed-out standalone rule offline.

    • Smallest fix: drop the !isOffline condition at RequireFieldsRulesUtils.ts:718 so pending-DELETE rows are hidden offline too (if (isPendingDelete) continue;), matching online behavior. Trade-off: a genuine offline delete of a rule would then also disappear immediately rather than showing a crossed-out row.
    • More surgical (preserves offline delete UX): only when handleSave performs a category reassignment, avoid the full deleteRequireFieldsRule that yields a crossed-out full-delete row — clear only the moving fields / tag the old category so the table treats it as reassigned rather than deleted. Larger, needs old→new correlation.

    The team should confirm the intended offline UX for a genuine rule deletion (crossed-out vs. immediate removal), which decides between the two.

    ⚠️ Deploy blocker: if a targeted fix can't land quickly, reverting #95312 is the fallback, though it removes a large feature.

    What alternative solutions did you explore? (Optional)

    N/A


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

  7. situchan commented on Jul 23, 2026

    @situchan
    Contributor

    This is same bug as reported here

  8. added
    Daily
    and removed
    DeployBlockerCash
    Hourly
    on Jul 23, 2026
  9. melvin-bot commented on Jul 28, 2026

    @melvin-bot

    @Krishna2323 Eep! 4 days overdue now. Issues have feelings too...

  10. JS00001 commented on Jul 29, 2026

    @JS00001
    Contributor

    @Krishna2323 have you gotten to this one yet?

  11. melvin-bot commented on Jul 30, 2026

    @melvin-bot

    @Krishna2323 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  12. Krishna2323 commented on Aug 3, 2026

    @Krishna2323
    Contributor

    Working on the PR...

  13. Krishna2323 commented on Aug 3, 2026

    @Krishna2323
    Contributor

    @JS00001 this is expected:

    Require-fields rules are stored per category, so changing the category offline is treated as delete on the old category + create on the new one. That’s why the original row is crossed out (pending delete) and a new row appears, instead of a single grayed-out update.

  14. JS00001 commented on Aug 3, 2026

    @JS00001
    Contributor

    Yeah i agree this looks expected

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

Metadata

Metadata

Labels

BugDailyEngineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions