App icon indicating copy to clipboard operation
App copied to clipboard

[$250] Report - When moving expense to another report after creating rule, "Submit" reappears

Open applause-bot[bot] opened this issue 2 months ago • 71 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.4.77-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: https://github.com/Expensify/App/pull/100940 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Motorola MotoG60 / Android 12 (Hybrid app) App Component: Money Requests

Action Performed:

Prerequisite: User is owner of a "Control" workspace. Prerequisite 2: "Categories" and "Rules" enabled.

  1. Open the Expensify app.
  2. Navigate to workspace chat.
  3. Create a manual expense.
  4. Open the just created expense.
  5. Tap on "Category" field and edit the category.
  6. Tap on "Create Rule" on the prompt displayed on report.
  7. Make any edition to the rule. (For example: Add a description)
  8. Enable the "Apply to existing unsubmitted expenses) toggle.
  9. Save the rule.
  10. Once redirected to report again, tap on the "Report" field > "Create Report"
  11. Note that after landing on empty report, "Mark as paid / Submit" button reappears briefly and background animation changes.

Expected Result:

After creating a new rule and moving expense to a new report, user should land on an empty report with "More" button visible on top and a "No expenses yet" animation above "Add Expense" button.

Actual Result:

When landing on empty report, after creating a new rule via prompt and moving expense to a new report, "More" button changes briefly to "Mark as paid / Submit" again, and "No expenses yet" animation with "Add Expense" button, also disappear briefly.

Workaround:

Unknown

Platforms:

  • [x] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [ ] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/f88084b5-bf87-4aa0-8a02-1d6455bd59ae

Image

View all open jobs on GitHub

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

Issue OwnerCurrent Issue Owner: @mukhrr
Upwork Automation - Do Not Edit

applause-bot[bot] avatar Sep 12 '26 08:09 applause-bot[bot]

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

https://platform.applause.com/services/links/v1/external/69eb43417899ce37553dd55de2c7a04fb7418dfb37e3aed75391148d52666531

applause-bot[bot] avatar Sep 12 '26 08:09 applause-bot[bot]

@JS00001 recently merged https://github.com/Expensify/App/pull/100940, but they are OOO right now, so I'll auto-assign someone else.

melvin-bot[bot] avatar Sep 12 '26 08:09 melvin-bot[bot]

Triggered auto assignment to @marcaaron (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] avatar Sep 12 '26 08:09 melvin-bot[bot]

:wave: 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.

github-actions[bot] avatar Sep 12 '26 08:09 github-actions[bot]

@JS00001 @situchan you have been assigned to this deploy blocker because you reviewed the offending PR: https://github.com/Expensify/App/pull/100940

melvin-bot[bot] avatar Sep 12 '26 08:09 melvin-bot[bot]

@Krishna2323 you have been assigned to this deploy blocker because you authored the offending PR: https://github.com/Expensify/App/pull/100940

melvin-bot[bot] avatar Sep 12 '26 08:09 melvin-bot[bot]

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

melvin-bot[bot] avatar Sep 12 '26 08:09 melvin-bot[bot]

🔍 Investigation Summary

Classification: Frontend bug Causing PR: #98662 - "Remove rulesRevamp beta." by @Krishna2323 (Low confidence — exposure vector only, not a logic regression). #100940 is ruled out (High confidence it is not the cause). Related Issues: #101012, #101013 (other blockers on the same checklist, unrelated)

Recommendation: NEEDS INVESTIGATION

No PR on the current StagingDeployCash checklist touches the code that produces this flicker, so reverting #100940 will not fix it — that PR only decides whether a "Create a rule" suggestion record is written, and touches none of the report footer, empty-state, or transaction↔report association code. This needs a runtime trace (or the Applause video/logs) to confirm which Onyx write momentarily re-attaches the moved expense to the old report; if it turns out to be a purely transient one-frame flicker with a correct end state, this is a DEMOTE candidate rather than a revert.

Assigned: No change. The current assignees (@Krishna2323 as author, @JS00001 and @situchan as approvers) happen to be exactly the author/approvers of #98662, the PR that made this flow reachable on staging, so they remain the right owners even though #100940 is exonerated. Labels: No changes. DeployBlockerCash is kept — the issue is not reproducible in production, and no App PR has been confidently identified as the cause. DeployBlocker was not present and was not added.

📋 Detailed Analysis

Evidence

Why #100940 is not the cause. Its diff is confined to gating the "Create a rule" offer: it threads transaction/parentReport into trackMerchantRuleSuggestion and adds early-returns for expenses a merchant rule could never match (missing merchant, distance, per diem, invoice, policy mismatch, edited-from-list). Its changed files are MerchantRuleSuggestion.ts, UpdateMoneyRequest.ts, TransactionInlineEdit.ts, MoneyRequestView.tsx, and five DynamicIOURequestStep* pages. None of those participate in computing the report's primary action, the report's empty state, or which report a transaction belongs to. The only thing #100940 influences in this repro is whether step 6's "Create Rule" prompt appears at all.

Why no other checklist PR is the cause. I pulled the changed-file list for all 28 App PRs in #100992 and cross-referenced them against the code paths involved. Nothing in the release touches src/components/MoneyRequestReportView/*, src/libs/ReportPrimaryActionUtils.ts, src/libs/actions/Transaction.ts, src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts, useTransactionsAndViolationsForReport, or the money report header. The only ReportUtils.ts edits in the release are #94628 (narrowing isInvoiceReport/isCategoryBeingAnalyzed signatures), #100596, and #100872 (Spotnana trip data) — all unrelated.

Staging vs production. Applause correctly marked this N/A in production. #98662 removed the rulesRevamp beta, which is what makes the "Create a rule" callout and the merchant rule page — including the "Apply to existing unsubmitted expenses" toggle — reachable for everyone on staging. So the flow is new; the report-move machinery it exercises is not.

Verification

Both reported symptoms ("Submit" returning and the "No expenses yet" state vanishing) collapse to a single underlying condition: for a moment, the old report is observed as still holding the moved expense.

So a single Onyx write that sets the moved transaction's reportID back to the old report reproduces both symptoms at once, and a subsequent corrective write clears them again — exactly the "briefly reappears" shape described.

Root Cause

The move itself is optimistic and correct. changeTransactionsReport merges reportID: <new report> onto the transaction (Transaction.ts#L1153-L1168), with matching successData reasserting the new reportID and failureData restoring the old one. And the "Create report" path schedules that optimistic write a microtask + one frame before the RHP finishes dismissing (DynamicIOURequestEditReport.tsx#L116-L141), which matches the reporter landing on a correctly empty report first.

The most likely mechanism for the regression back to "Submit" is a server payload for a request issued before the move landing after it, carrying the transaction with its pre-move reportID. Step 8 is what makes this window wide: saving the rule with "Apply to existing unsubmitted expenses" sends shouldUpdateMatchingTransactions and ships no optimistic transaction data at all (Rules.ts#L274-L281) — every transaction change from that rule arrives later, from the backend, as a full transaction merge. A rule-application update (or an OpenReport read for the freshly revealed report, since reads are not ordered behind the queued ChangeTransactionsReport write) that was computed before the move will re-assert the old reportID, bounce the expense back into the old report's bucket for a frame or two, and then get corrected by ChangeTransactionsReport's own response.

That would make the fix a targeted one, not a revert — either stop the rule-application/read payloads from re-asserting reportID for a transaction with an in-flight move, or hold the reveal until the move write settles. I want to stress that this last step is inference from the code, not confirmed from logs: I could not reproduce it here, and the Applause attachments would pin down the exact ordering. Flagging it as such rather than asserting a root cause I haven't proven.

MelvinBot avatar Sep 12 '26 08:09 MelvinBot

Looks like this is caused by https://github.com/Expensify/App/pull/98662, which was confirmed by QA

JS00001 avatar Sep 14 '26 17:09 JS00001

This is really strange & unlikely user path, with a small ux issue, lets fix this in a follow up but not block the release

JS00001 avatar Sep 14 '26 17:09 JS00001

I reproduced this in production too. Happens when move expense to another report as soon as rule is created.

Repro step:

  1. Create a draft expense
  2. Open expense detail and Move to report in header menu
  3. While in Move report page, open 2nd tab
  4. Create a new rule with the same merchant, toggle "Apply to existing unsubmitted expenses" on so that the rule applies to existing expense
  5. Click "Save rule" and then quickly switch to 1st tab and click "Create report"

https://github.com/user-attachments/assets/65a9fe68-f447-4e33-91dd-2711c0153e18

situchan avatar Sep 14 '26 21:09 situchan

@Krishna2323 can we try to fix this in a follow up? If its completely unrelated, we can also make this external

JS00001 avatar Sep 17 '26 11:09 JS00001

PR will be up shortly.

Krishna2323 avatar Sep 21 '26 13:09 Krishna2323

Thanks!

JS00001 avatar Sep 21 '26 13:09 JS00001

@situchan, are you able to reproduce the issue? I can't:

https://github.com/user-attachments/assets/80e5c047-6bc1-463f-af8b-6587104bc35d

Krishna2323 avatar Sep 21 '26 15:09 Krishna2323

You should do actions quickly to make race condition. Maybe try on web like I did here rather than slow android emulator? Same root cause.

situchan avatar Sep 21 '26 16:09 situchan

@Krishna2323 were you able to repro this?

JS00001 avatar Sep 23 '26 16:09 JS00001

@marcaaron @JS00001 @Krishna2323 @situchan this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

melvin-bot[bot] avatar Sep 26 '26 21:09 melvin-bot[bot]

@JS00001 I tried again but still can't repro this. Can we ask for a reset?

Krishna2323 avatar Sep 28 '26 03:09 Krishna2323