Skip to content

Allow pendingAction and pendingFields to be merged into search snapshots even when those keys were not previously present#723

Merged
luacmartins merged 8 commits intoExpensify:mainfrom
marufsharifi:fix/merge-pending-fields-into-search-snapshots
Feb 4, 2026
Merged

Allow pendingAction and pendingFields to be merged into search snapshots even when those keys were not previously present#723
luacmartins merged 8 commits intoExpensify:mainfrom
marufsharifi:fix/merge-pending-fields-into-search-snapshots

Conversation

@marufsharifi
Copy link
Contributor

@marufsharifi marufsharifi commented Jan 22, 2026

Details

Added snapshotMergeKeys to Onyx.init options and global settings so apps can opt in to extra snapshot fields without hardcoding app-specific keys in Onyx.
Updated updateSnapshots to merge existing snapshot keys plus configured allowlist keys (if present on the updated value).
Added unit test coverage to verify that allowlisted keys are merged into snapshots even when missing originally.

Related Issues

Expensify/App#69559

Automated Tests

Added required unit tests.

Manual Tests

  1. Create workspace
  2. Create a manual expense
  3. Go to Reports > Reports
  4. Switch to offline mode
  5. Go back to the workspace chat and delete the just-created expense
  6. Get back to the Reports > Reports, verify that the row is grayed out as deleted.

Author Checklist

  • I linked the correct issue in the ### Related Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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 proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop
Screen.Recording.1404-11-15.at.5.44.57.PM.mov

…ots even when those keys were not previously present
@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@marufsharifi
Copy link
Contributor Author

@eVoloshchak, this is my first pr in this repo. Where do I need to test and create records for? Could you please give a little details on every section of the checklist? thanks.

@marufsharifi
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

CLABotify added a commit to Expensify/CLA that referenced this pull request Jan 22, 2026
@fabioh8010
Copy link
Contributor

Hi @marufsharifi Do you plan to move ahead with this PR? In general it isn't a good direction because we are introducing Expensify product-specific logic into Onyx.

cc @luacmartins @tgolen

@marufsharifi
Copy link
Contributor Author

@luacmartins, waiting for your thoughts on this.

@luacmartins
Copy link
Contributor

I think the way to do this would be to expose a config to App and pass the keys we want to merge regardless via that config prop.

@tgolen
Copy link
Collaborator

tgolen commented Jan 24, 2026

Yeah, I agree that a config option would be a better route to go.

@fabioh8010
Copy link
Contributor

Could you explain me what's the reason behind this change? Is there a discussion or thread where I could find the proposal/idea?

@marufsharifi
Copy link
Contributor Author

@fabioh8010, please check this PR.

@marufsharifi
Copy link
Contributor Author

@fabioh8010, @luacmartins, just to confirm, should i procced with this PR? Thanks.

@fabioh8010
Copy link
Contributor

@marufsharifi Could you elaborate a formal proposal how you plan to make this change in Onyx, so everyone is aligned about the RCA and solution?

@marufsharifi
Copy link
Contributor Author

formal proposal

@fabioh8010, should I post the proposal in this Pr? Thanks.

@fabioh8010
Copy link
Contributor

It's ok for me, @luacmartins @tgolen do you agree?

@luacmartins
Copy link
Contributor

Sure

@fabioh8010
Copy link
Contributor

@marufsharifi Any news here?

@marufsharifi
Copy link
Contributor Author

Proposal

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

When deleting expenses from search while offline, the UI doesn’t show the correct “pending delete” state because search results come from snapshot data that doesn’t include pendingAction/pendingFields when those keys weren’t already present.

What is the root cause of that problem?

Onyx snapshot merging only copies keys that already exist in the snapshot object. Since pendingAction and pendingFields are often missing from snapshot entries, updates to those fields aren’t merged, so search snapshots never reflect the pending delete state.

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

Add a configurable allowlist of keys that should always be merged into snapshot entries, even if missing. Expose this config at Onyx initialization so App can opt in to merging pendingAction and pendingFields (without hardcoding Expensify-specific behavior inside Onyx).

What alternative solutions did you explore? (Optional)

@marufsharifi
Copy link
Contributor Author

finalizing the pr.

@marufsharifi marufsharifi marked this pull request as ready for review January 30, 2026 16:05
@marufsharifi marufsharifi requested a review from a team as a code owner January 30, 2026 16:05
@melvin-bot melvin-bot bot requested review from mjasikowski and removed request for a team January 30, 2026 16:05
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e93c687394

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@marufsharifi
Copy link
Contributor Author

@fabioh8010, could you please share a guide for the PR checklist in this repo?

@fabioh8010
Copy link
Contributor

I will review it soon

Copy link
Contributor

@fabioh8010 fabioh8010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

About the proposal -> LGTM

@marufsharifi
Copy link
Contributor Author

@fabioh8010, please take another look when you get a chance, i've addressed your feedback.

tgolen
tgolen previously approved these changes Feb 2, 2026
Copy link
Collaborator

@tgolen tgolen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The comments are better now.

mjasikowski
mjasikowski previously approved these changes Feb 3, 2026
@marufsharifi
Copy link
Contributor Author

@fabioh8010, could you please check this comment? thanks.

luacmartins
luacmartins previously approved these changes Feb 3, 2026
Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luacmartins
Copy link
Contributor

@marufsharifi lint is failing

tgolen
tgolen previously approved these changes Feb 3, 2026
@fabioh8010
Copy link
Contributor

@fabioh8010, could you please check this comment? thanks.

@marufsharifi You basically need to fill the sections/checklist as usual, like you do for E/App PRs.

In Automated Tests you should specify whether you added unit tests, and in case none were added it should have a justification for that.

In Manual Tests you are going to put the test plan that proves the PR it's fixing, same as E/App.

In Screenshots/Videos you attach the media related to your manual tests.

@marufsharifi marufsharifi dismissed stale reviews from tgolen, luacmartins, and mjasikowski via 322c9d3 February 4, 2026 11:11
@marufsharifi
Copy link
Contributor Author

There was a prettier failure I fixed, and it dismissed all the reviews. @luacmartins, could you please check again and merge? Thanks.

cc @tgolen, @mjasikowski

@luacmartins luacmartins merged commit 147a0f6 into Expensify:main Feb 4, 2026
8 checks passed
@os-botify
Copy link
Contributor

os-botify bot commented Feb 4, 2026

🚀 Published to npm in 3.0.33 🎉

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants