Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/CurrentUserPersonalDetailsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function CurrentUserPersonalDetailsProvider({children}: {children: React.ReactNo
},
[session?.email, userAccountID],
);
const [currentUserPersonalDetails = defaultCurrentUserPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: userAccountSelector, canBeMissing: true});
const [currentUserPersonalDetails = defaultCurrentUserPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: userAccountSelector, canBeMissing: true}, [
userAccountSelector,

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.

❌ PERF-6 (docs)

Passing entire objects or functions as dependencies causes hooks to re-execute whenever any property changes, even unrelated ones. Specifying individual properties creates more granular dependency tracking, reducing unnecessary hook executions and improving performance predictability.

Since userAccountSelector depends on session?.email and userAccountID (line 27), the dependency array should specify these individual properties instead:

const [currentUserPersonalDetails = defaultCurrentUserPersonalDetails] = useOnyx(
    ONYXKEYS.PERSONAL_DETAILS_LIST, 
    {selector: userAccountSelector, canBeMissing: true}, 
    [session?.email, userAccountID]
);

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.

@lorretheboy Can you fix this?

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.

@shubham1206agra I think we can keep it as we add selector as dependency as a common pattern in our codebase. Do u think so?

[tripTransactionsSelector],

]);

return <CurrentUserPersonalDetailsContext.Provider value={currentUserPersonalDetails}>{children}</CurrentUserPersonalDetailsContext.Provider>;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/SessionTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('Deep linking', () => {

await waitForBatchedUpdates();

expect(lastVisitedPath).toBe(`/${ROUTES.REPORT}/${report.reportID}`);
expect(lastVisitedPath).toBe(`/${ROUTES.HOME}`);

@lorretheboy lorretheboy Nov 12, 2025 •

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.

Need to update to HOME since currentUserPersonalDetails is updated when userAccountSelector changes (which happens when session?.email or userAccountID changes during sign-in). Besides, I tested the transition flow, it works fine. Please correct me if I'm wrong

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.

False, this led to failing tests on main, see https://expensify.slack.com/archives/C01GTK53T8Q/p1765191955953569

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.


expect(hasAuthToken()).toBe(true);

Expand Down