Fix: preserve untouched tag levels when bulk-editing a single tag level - #97951
Fix: preserve untouched tag levels when bulk-editing a single tag level#97951MelvinBot wants to merge 6 commits into
Conversation
Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
…pre-computes Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
Fixed the failing spellcheck check. The check flagged two non-dictionary words in
Spellcheck now passes locally and all 35 tests in The other two failing checks — |
|
@MelvinBot Could you pease review #97951 (comment) and #97951 (comment) comment? |
Screenshots/VideosMacOS: Chrome / SafariScreen.Recording.2026-08-06.at.17.20.51.movScreen.Recording.2026-08-06.at.17.22.42.mov |
Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
|
1. Codecov (coverage report) — no bug, and the core fix is actually better covered.
2. Spellcheck fix (my earlier comment) — verified correct.
Net: the only actionable item was the untested |
|
The spellcheck fix from earlier is now passing, and the only remaining failing checks are non-code process checks that I can't resolve by pushing code:
All other real checks (spellcheck, ESLint, typecheck, Bun tests, build, etc.) are passing or still running. Nothing further for me to fix here. |
sobitneupane
left a comment
There was a problem hiding this comment.
Screenshots/Videos
Android: HybridApp
Screen.Recording.2026-08-07.at.17.10.38.mov
Android: mWeb Chrome
Screen.Recording.2026-08-07.at.17.08.28.mov
iOS: HybridApp
Screen.Recording.2026-08-07.at.17.47.52.mov
iOS: mWeb Safari
Screen.Recording.2026-08-07.at.17.51.19.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-07.at.17.04.48.mov
|
There's nothing for me to fix here — all the code, build, and test checks are green. The only failing checks are process checks that require human action, not a code change:
I intentionally don't push commits for these — they're satisfied by people, not by MelvinBot. Once the checklists are filled out and the PR has an independent approval, these will go green. For reference, everything else is passing: |
|
Nothing has changed since my previous comment — there's still no code failure for me to fix. The only failing checks are process/human checks:
These are satisfied by people, not by a commit, so there's nothing for me to push. Every code, build, and test check ( |
|
@MelvinBot Please add the following steps under Tests and QA Steps:
@MelvinBot Additionally, please update the PR Author Checklist and mark all items as completed.
|
|
🤖 Done — updated the PR description:
One heads-up: the Screenshots/Videos section is still empty, so the "I included screenshots or videos for tests on all platforms" box now claims something the PR body doesn't yet show. Adding the platform screenshots/videos will keep that checkbox honest before the PR goes up for review. |
|
@MelvinBot Mark this PR ready for review |
sobitneupane
left a comment
There was a problem hiding this comment.
Reviewer Checklist
- I have verified the author checklist is complete (all boxes are checked off).
- I verified the correct issue is linked in the
### Fixed Issuessection above - I verified testing steps are clear and they cover the changes made in this PR
- I verified the steps for local testing are in the
Testssection - I verified the steps for Staging and/or Production testing are in the
QA stepssection - I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
- I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
- I verified the steps for local testing are in the
- I checked that screenshots or videos are included for tests on all platforms
- I included screenshots or videos for tests on all platforms
- I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
- I verified tests pass on all platforms & I tested again on:
- Android: HybridApp
- Android: mWeb Chrome
- iOS: HybridApp
- iOS: mWeb Safari
- MacOS: Chrome / Safari
- If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
- I verified proper code patterns were followed (see Reviewing the code)
- I verified that comments were added to code that is not self explanatory
- I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
- I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
- If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
- I verified that this PR follows the guidelines as stated in the Review Guidelines
- I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like
Avatar, I verified the components usingAvatarhave been tested & I retested again) - If a new component is created I verified that:
- A similar component doesn't exist in the codebase
- All props are defined accurately
- The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
- The only data being stored in the state is data necessary for rendering and nothing else
- The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
- If a new CSS style is added I verified that:
- A similar style doesn't already exist
- The style can't be created with an existing StyleUtils function (i.e.
StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
- If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
- If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like
Avataris modified, I verified thatAvataris working as expected in all cases) - If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
- If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
- If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
- I verified that all the inputs inside a form are aligned with each other.
- I added
Designlabel and/or tagged@Expensify/designso the design team can review the changes.
- For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
- If the
mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps. - I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
Screenshots/Videos
Android: HybridApp
Screen.Recording.2026-08-07.at.17.10.38.mov
Android: mWeb Chrome
Screen.Recording.2026-08-07.at.17.08.28.mov
iOS: HybridApp
Screen.Recording.2026-08-07.at.17.47.52.mov
iOS: mWeb Safari
Screen.Recording.2026-08-07.at.17.51.19.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-07.at.17.04.48.mov
|
@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
🤖 Done — this PR is now marked Ready for review. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6265f5f9b3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Keep the flattened tag for the summary display, and record the per-level edit intent so | ||
| // apply time can merge it into each transaction's own tag instead of overwriting all levels. | ||
| tag: updatedTag, | ||
| bulkEditTagChanges: {[tagListIndex]: resolvedTagName}, |
There was a problem hiding this comment.
Clear stale child tag edits when parents change
If a user edits a child tag level and then edits a parent level in the same bulk-edit draft, this merge writes only the new parent key and leaves the earlier child key in bulkEditTagChanges. Apply time sorts and replays all retained keys, so the stale child selection is applied after the parent change even though the displayed updatedTag cleared children; for dependent tags this can preserve or send an invalid child that the later parent edit was supposed to clear. Clear descendant entries (or replace the intent map) when saving a parent-level edit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
I don’t think this is reproducible. With dependent tags, when the parent tag changes, the child tag is automatically deselected if it doesn’t belong to the selected parent’s branch.
| // value (empty = clear) lets apply time force-set each transaction's level without re-deriving | ||
| // the toggle from that transaction's own value, which would misfire when an expense already | ||
| // has the selected value at this level. | ||
| const resolvedTagName = selectedTagName === currentTag ? '' : selectedTagName; |
There was a problem hiding this comment.
Carry tag clear intents when the tag becomes empty
When the user deselects the only tag, or clears the first level of a dependent tag, resolvedTagName becomes '' and updatedTag can also be ''. The save path only adds changes.tag for truthy draft tags, and updateMultipleMoneyRequests only reads bulkEditTagChanges inside its changes.tag branch, so this newly recorded clear intent is skipped (or the page dismisses as having no changes) instead of clearing the selected transactions' tags.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@MelvinBot Could you please review above comment?
There was a problem hiding this comment.
🤖 I reviewed this comment — it's a valid concern (real bug), not a false positive.
When the bulk tag edit resolves to an empty string (deselecting the only tag on a single independent tag list, or clearing level 0 of a dependent tag), the recorded clear intent in bulkEditTagChanges never reaches the transactions because it's gated behind a truthy tag check at two points:
- Save handler —
SearchEditMultiplePage.tsx:170:if (draftTransaction.tag)is falsy for'', sochanges.tagis never set. If the tag was the only edit,SearchEditMultiplePage.tsx:183then seesObject.keys(changes).length === 0and dismisses with no update at all. - Action —
BulkEdit.ts:242:if (changes.tag && ...)guards the wholebulkEditTagChangesreconstruction block, so even when other fields are edited and the action does run, the empty clear intent is skipped.
The intent itself is recorded correctly (bulkEditTagChanges: {index: ''} in SearchEditMultipleTagPage.tsx:51) — it just can't get past the two truthy gates, so the selected transactions' tags are never cleared.
For comparison, category one line up uses changes.category !== undefined precisely so an empty value clears the field — tag needs the same treatment.
Suggested fix: treat "a bulkEditTagChanges entry exists" as reason to proceed even when the resolved tag is empty — set changes.tag in the save handler when bulkEditTagChanges is non-empty (even if tag === ''), and enter the tag branch in BulkEdit.ts when bulkEditTagChanges has keys rather than only when changes.tag is truthy.
Note this differs from the sibling comment you marked non-reproducible: the trigger here is deselecting down to an empty tag, which the picker does allow. If you'd like, reply @MelvinBot implement this and I'll push the fix + a unit test covering the clear-to-empty case.
There was a problem hiding this comment.
🤖 Implemented in 6322557.
The clear-to-empty edit was being dropped by three truthy tag checks, so I fixed all three so an empty resolved tag is treated as a real change (mirroring how category uses !== undefined):
- Save handler —
SearchEditMultiplePage.tsx:170-176: now setschanges.tagwhenever the draft recorded abulkEditTagChangesintent, even when the resolved tag is''. - Action guard —
BulkEdit.ts:242-244: enters the tag branch onchanges.tag !== undefined || editedTagIndexes.length > 0, so the per-transaction reconstruction still runs for an empty clear. - Updates payload —
BulkEdit.ts:305-307:if (transactionChanges.tag !== undefined)so the cleared''is forwarded instead of leavingupdatesempty (which was causing the whole transaction to be skipped).
That last one wasn't in my earlier analysis — the empty tag would have been dropped there too, so I caught it while implementing.
Added a unit test covering deselecting the only tag on a single independent tag list (BulkEditTest.ts), asserting the update clears the tag to '' rather than being dropped.
category pattern.
| transactionIDs: [firstTransactionID, secondTransactionID], | ||
| // The bulk-edit page pre-computes a common-prefix display string (parent only)... | ||
| changes: {tag: 'CostCenterB'}, | ||
| // ...but apply time uses the resolved per-level edit intent (index 0 -> CostCenterB) to |
There was a problem hiding this comment.
❌ CONSISTENCY-16 (docs)
This comment uses an arrow (->) inside its own sentence instead of writing the relationship out in words, which the plain-comment-style rule flags.
Rewrite the relationship in words, e.g.:
// ...but apply time uses the resolved per-level edit intent (index 0 maps to CostCenterB) toReviewed at: 6265f5f | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Done in bb2787b — rewrote the arrow as (index 0 maps to CostCenterB).
| getCurrencySymbol, | ||
| }); | ||
|
|
||
| // Each transaction keeps its OWN Indication/Phase; only the shared parent level changed. |
There was a problem hiding this comment.
❌ CONSISTENCY-16 (docs)
This comment joins two independent clauses with a semicolon. Plain comment style prefers two separate sentences over a semicolon.
Split into two sentences, e.g.:
// Each transaction keeps its OWN Indication/Phase. Only the shared parent level changed.Reviewed at: 6265f5f | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Done in bb2787b — split into two sentences: Each transaction keeps its OWN Indication/Phase. Only the shared parent level changed.
| getCurrencySymbol, | ||
| }); | ||
|
|
||
| // Parent (CostCenter) preserved; the edited Indication level updated; dependent Phase cleared. |
There was a problem hiding this comment.
❌ CONSISTENCY-16 (docs)
This comment uses semicolons to string together three independent clauses. Plain comment style prefers separate sentences over semicolons.
Split into separate sentences, e.g.:
// The parent (CostCenter) is preserved. The edited Indication level is updated. The dependent Phase level is cleared.Reviewed at: 6265f5f | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Done in bb2787b — split into three sentences: Parent (CostCenter) is preserved. The edited Indication level is updated. The dependent Phase level is cleared.
|
No failing checks to fix right now — every automated check on the PR is passing (Bun tests, ESLint, typecheck, all The only two not yet green are |
|
Still the same situation — the only failing check is Everything else is green, including |
|
@MelvinBot Could you please review #97951 (comment), #97951 (comment) and #97951 (comment) comments? |
|
Same as before — the only failing check is |
|
Same as before: the only failing check is Nothing for me to fix or push here; this clears once the PR gets an independent approval. |
|
There are no failing checks on the PR right now — nothing to fix. Current status: 39 passing, 4 skipped, and 2 still in progress ( No commit needed here. |
Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
|
@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Reviewed all three — they're the same automated
All comment-text only — no logic or test behavior changed. I've replied in each thread as well. |
|
Still nothing to fix by pushing code. A fresh CI run is in progress and all the real checks that have finished are green (ESLint, typecheck, The only failure is |
When a bulk Edit multiple deselects the only tag (or clears level 0 of a dependent tag), the edit resolved to an empty string and was silently dropped by three truthy checks: the save handler skipped changes.tag, the action's tag branch never ran, and the updates payload never included the empty tag. Gate these on the recorded per-level edit intent / definedness (matching category) so the clear reaches the transactions. Adds a unit test for the clear case. Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6322557c34
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Keep the flattened tag for the summary display, and record the per-level edit intent so | ||
| // apply time can merge it into each transaction's own tag instead of overwriting all levels. | ||
| tag: updatedTag, | ||
| bulkEditTagChanges: {[tagListIndex]: resolvedTagName}, |
There was a problem hiding this comment.
Clear stale child tag intents when saving parents
Fresh evidence after checking the current diff: this stores only the edited index into a draft object that is updated with Onyx.merge, while updateMultipleMoneyRequests later replays every retained bulkEditTagChanges key in ascending order. If a user first edits a dependent child level and then changes the parent before saving, the parent edit clears the displayed updatedTag, but the stale child key remains and is applied after the parent clear, so the saved transactions can keep/send a child value that no longer belongs to the selected parent. Replace the intent map when saving a parent level or clear descendant keys here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🤖 Confirmed valid, fixed in 5166454.
The draft's bulkEditTagChanges is written with Onyx.merge, so it accumulates one key per edited level across the draft. If a user edits a child level and then a parent level, the map keeps both keys, and apply time replays them in ascending index order (BulkEdit.ts:256-266) — so the stale child is re-applied after the parent change, re-adding a child that no longer belongs under the new parent, even though the displayed updatedTag had already cleared it.
Fix: when recording an edit for a dependent-tag policy, drop any previously recorded child (deeper-index) intents from the draft (SearchEditMultipleTagPage.tsx:69-83), mirroring how updatedTag already clears the display. Independent tags are unaffected — each level stays independent, so all recorded levels are retained.
Verified typecheck, lint, and React Compiler compliance pass, and the existing BulkEditTest suite (36 tests) is still green. Note this scenario lives in the picker's draft-recording path rather than updateMultipleMoneyRequests, so it isn't covered by the action-layer suite — a component-level test for the multi-level edit sequence would be a good follow-up.
… in bulk edit Co-authored-by: Sobit Neupane <sobitneupane@users.noreply.github.com>
|
@MelvinBot When I open the parent tag in “Edit Multiple,” it appears as already selected. However, I need to deselect and reselect it for the child tag menu to show up. In staging, the behavior is different, already selected tags don’t appear as selected in the list when I first open “Edit Multiple.” Should we align this flow and follow the same approach? |
|
Good catch — this is a real side effect of one intentional line in this PR, and I'd not do a straight revert to staging's behavior, because staging's approach reintroduces the exact bug this line was added to fix. The PR seeds Recommendation: Rather than aligning to staging, decouple the two things this one line currently conflates — keep highlighting the existing shared value (it's informative and matches single-expense editing), but drive the select-vs-deselect toggle off whether the value is actually committed in the draft rather than off the seeded common value. That fixes the child-navigation flow while still letting a second tap clear the level. Worth confirming the target matches the single-expense dependent-tag picker, which is the source of truth for consistency. Why (mechanism + the tension)On this PR — The child (deeper) level only renders once the parent is present in the committed draft tag — Why staging can't just be restored — Staging seeds (Mechanism confirmed by code trace; it's deterministic client-side logic, matching what you reproduced.) |
@MelvinBot Could you please clarify how not selecting any option (as in staging) would reintroduce the original bug?
Also, could you please elaborate a bit more on the two things you mentioned and how you are planning of decoupling them? |
|
Both good questions — and the second one made me tighten my own recommendation, because the "drive the toggle off the draft" phrasing I used would have partly reintroduced the bug. Details below. Q1 — Why staging's "nothing selected" reintroduces the original bug The only thing that produces a clear for dependent tags is Staging seeds Q2 — The two things this one line conflates, and the right way to decouple The single common-seeded
Because both read the same value, the first tap on the highlighted parent resolves to a clear ( Correction to what I said earlier: I framed the fix as "drive the toggle off whether the value is committed in the draft." On a closer trace that's the wrong lever — with the toggle reading the (empty) draft, the first tap on the highlighted value becomes a no-op re-select and clearing a shared level would again take two taps, i.e. it re-introduces the Q1 limitation. So don't touch the toggle. The clean decouple is to leave the toggle seeded from the common tag (keeps 1-tap deselect / the original fix intact) and fix what's actually broken — child-list visibility. It's currently gated on the committed draft (
Worth validating the target against the single-expense dependent-tag flow, which is the source of truth for how the highlight, one-tap clear, and child-field visibility should behave together. If you'd like, reply |
trjExpensify
left a comment
There was a problem hiding this comment.
- Log in to New Expensify
- Open report
- Select all expenses in the report
- Click Edit multiple
- Update only the parent tag level.
- Save the changes
- Open the edited expenses and review the tag values
- Verify that only the parent tag level is updated, and the existing child tag levels on each expense remain unchanged.
Might be best to write a test for dependent tags and independent tags? It's not super clear for Applause what to set up on a workspace to test this as written.
|
@MelvinBot Could you please update the test and QA steps to the following: Precondition: Create workspace, import multi-level independent tags and create a report with at least two expenses.
|
|
Updated both the Tests and QA Steps sections to your steps: Precondition: Create workspace, import multi-level independent tags and create a report with at least two expenses.
I kept the existing "Verify that no errors appear in the JS console" checkbox line under each section. |
Explanation of Change
Bulk Edit multiple built a single flat tag string in the UI (seeded from only the common prefix shared by all selected expenses) and overwrote that same string onto every transaction. When expenses shared a parent tag level (e.g.
Cost Center) but differed on child levels (Indication,Phase), the children were dropped from the common prefix before any edit and then wiped from every expense on save.This change applies the tag edit per-transaction instead of precomputing one shared string:
bulkEditTagChanges, in addition to the flattenedtagit still stores for the summary display.updateMultipleMoneyRequestsreconstructs the tag from each transaction's own current tag by running the existinggetUpdatedTransactionTagmerge at the edited index, against that transaction's real workspace policy. Levels the user didn't touch are preserved (independent tags) or intentionally cleared below the edited level (dependent tags), matching single-expense editing.currentTagwas read from the empty draft instead of the common tag.The approach is level-count agnostic: for 3+ levels, editing a middle level preserves the parent(s) above at any depth (and, for dependent tags, clears the now-invalid child below by design).
New unit tests cover independent tags (children preserved) and dependent tags (parent preserved, dependent child cleared, middle-level edit).
Fixed Issues
$ #97356
PROPOSAL: #97356 (comment)
Tests
Precondition: Create workspace, import multi-level independent tags and create a report with at least two expenses.
Offline tests
QA Steps
Precondition: Create workspace, import multi-level independent tags and create a report with at least two expenses.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari