Skip to content

Remove initWithStoredValues from Onyx#782

Open
fabioh8010 wants to merge 4 commits intoExpensify:mainfrom
callstack-internal:feature/remove-initWithStoredValues
Open

Remove initWithStoredValues from Onyx#782
fabioh8010 wants to merge 4 commits intoExpensify:mainfrom
callstack-internal:feature/remove-initWithStoredValues

Conversation

@fabioh8010
Copy link
Copy Markdown
Contributor

@fabioh8010 fabioh8010 commented May 4, 2026

Details

Removes initWithStoredValues from Onyx as the final task of Expensify/App#80091.

E/App PR: Expensify/App#89488

Related Issues

Expensify/App#80091

Automated Tests

Unit tests removed.

Manual Tests

We just need to test the removal of the last initWithStoredValues that was introduced in Expensify/App#81973. Use Expensify/App#89488 for testing:

  1. Open app
  2. Go to domain/domainID/members
  3. Select several members
  4. Click the primary action button and verify that the Move to group action there
  5. Select a different group to move to
  6. Click Save
  7. Assert the members are not selected anymore and their group have changed

  1. Open app
  2. Go to domain/domainID/members
  3. Select several members
  4. Reload the browser/app
  5. Assert they are not selected anymore

  1. Open app
  2. Go to domain/domainID/members
  3. Select several members
  4. Click the primary action button and verify that the Move to group action there
  5. Select a different group to move to
  6. Reload the browser/app
  7. Assert you are back to members page and the members are not selected anymore

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
  • 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

N/A, emulator crashing for me

Android: mWeb Chrome
Screen.Recording.2026-05-06.at.13.41.05.mov
iOS: Native
Screen.Recording.2026-05-06.at.13.50.44.mov
iOS: mWeb Safari
Screen.Recording.2026-05-06.at.13.54.43.mov
MacOS: Chrome / Safari
Screen.Recording.2026-05-06.at.13.56.24.mov
Screen.Recording.2026-05-06.at.13.57.26.mov

@fabioh8010
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

@fabioh8010 fabioh8010 changed the title [WIP] Remove initWithStoredValues from Onyx Remove initWithStoredValues from Onyx May 6, 2026
@fabioh8010 fabioh8010 marked this pull request as ready for review May 6, 2026 13:06
@fabioh8010 fabioh8010 requested a review from a team as a code owner May 6, 2026 13:06
@melvin-bot melvin-bot Bot requested review from cristipaval and removed request for a team May 6, 2026 13:07
@fabioh8010
Copy link
Copy Markdown
Contributor Author

Ready to review @roryabraham @Krishna2323 @Julesssss

@tgolen tgolen self-requested a review May 6, 2026 16:23
@Krishna2323
Copy link
Copy Markdown
Contributor

I'll review tomorrow morning.

@Julesssss Julesssss requested review from Julesssss and Krishna2323 May 6, 2026 18:11
@Julesssss
Copy link
Copy Markdown
Contributor

Running QA testing on the App AdHoc build

Comment thread lib/OnyxUtils.ts Outdated
Comment thread tests/unit/OnyxSnapshotCacheTest.ts Outdated
Comment thread lib/OnyxSnapshotCache.ts Outdated
// Create options hash without expensive JSON.stringify
const initWithStoredValues = options?.initWithStoredValues ?? true;
const cacheKey = `${selectorID}_${initWithStoredValues}`;
const cacheKey = `${selectorID}`;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this keep the _ underscore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No need anymore as it was only necessary to concat the initWithStoredValues option, which was necessary to differentiate cache keys. Since we don't have it anymore we can just use String(selectorID) that I adjusted in d83e8b7

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OK, thank you for confirming!

@fabioh8010 fabioh8010 requested review from Julesssss and tgolen May 7, 2026 08:12
@fabioh8010
Copy link
Copy Markdown
Contributor Author

I don't know why but Typecheck and Jest reported strange failures that I don't have locally, for example TS one:

Error: tests/unit/onyxUtilsTest.ts(274,17): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'CollectionConnectOptions<string>'.
Error: tests/unit/onyxUtilsTest.ts(302,98): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'ConnectOptions<`${string}1`>'.
Error: tests/unit/onyxUtilsTest.ts(303,98): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'ConnectOptions<`${string}2`>'.
Error: tests/unit/onyxUtilsTest.ts(304,98): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'ConnectOptions<`${string}3`>'.
Error: tests/unit/onyxUtilsTest.ts(336,17): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'CollectionConnectOptions<string>'.
Error: tests/unit/onyxUtilsTest.ts(341,17): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'ConnectOptions<string>'.
Error: tests/unit/onyxUtilsTest.ts(372,17): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'CollectionConnectOptions<string>'.
Error: tests/unit/onyxUtilsTest.ts(378,17): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'CollectionConnectOptions<string>'.
Error: tests/unit/onyxUtilsTest.ts(411,98): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'ConnectOptions<`${string}1`>'.
Error: tests/unit/onyxUtilsTest.ts(412,98): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'ConnectOptions<`${string}2`>'.
Error: tests/unit/onyxUtilsTest.ts(454,17): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'DefaultConnectOptions<string>'.
Error: tests/unit/onyxUtilsTest.ts(489,17): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'ConnectOptions<string>'.
Error: tests/unit/onyxUtilsTest.ts(494,17): error TS2353: Object literal may only specify known properties, and 'initWithStoredValues' does not exist in type 'ConnectOptions<string>'.
Error: Process completed with exit code 2.

This doesn't make any sense as we don't even have initWithStoredValues anymore in the codebase. Could we trigger the CI again?

@tgolen
Copy link
Copy Markdown
Collaborator

tgolen commented May 7, 2026

Restarted them 👍

tgolen
tgolen previously approved these changes May 7, 2026
@fabioh8010
Copy link
Copy Markdown
Contributor Author

Oh it was because the branch was behind main, updated it and now it should work!

@Krishna2323
Copy link
Copy Markdown
Contributor

Reviewing...

Comment thread lib/OnyxUtils.ts
if (hasChanged) {
cache.set(key, value);
if (!hasChanged) {
return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fabioh8010 broadcastUpdate now early-returns when hasChanged is false — meaning no subscribers get notified for same-value writes. Previously initWithStoredValues: false subscribers would still be notified in that case. Is this intentional?

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.

4 participants