Repository navigation
Description
Problem
OnyxUtils.get() (imported from the internal deep path react-native-onyx/dist/OnyxUtils) is not a sanctioned way to read Onyx data. The only two supported read APIs are:
useOnyx()— for anything in a component's render path.Onyx.connectWithoutView()— for non-render logic that genuinely can't useuseOnyx.
Reaching into react-native-onyx/dist/* bypasses the public API and couples us to Onyx internals.
This issue covers src/components/GPSTripStateChecker/index.native.tsx, which contains one OnyxUtils.get(ONYXKEYS.GPS_DRAFT_DETAILS) call (as of writing, line 42, inside the mount useEffect).
Why useOnyx here
This is a React component — and it already subscribes to the same key via useOnyx(ONYXKEYS.GPS_DRAFT_DETAILS) (as of writing, line 29). Components that can use useOnyx should use it; the mount-effect read should be served from that subscription rather than a raw OnyxUtils.get().
The effect runs once on mount to answer "is there a persisted in-progress trip on app restart?" Because useOnyx resolves asynchronously on first render, the implementation should read the value once it has loaded — e.g. gate the mount logic on the useOnyx loading status (the second tuple element / status), or mirror the value into a ref for the effect to read. Avoid reintroducing a separate one-shot read.
Proposed change
- Remove the
import OnyxUtils from 'react-native-onyx/dist/OnyxUtils'. - Serve the
handleGpsTripInProgressOnAppRestartread from the existinguseOnyx(ONYXKEYS.GPS_DRAFT_DETAILS)subscription (gating on loaded status / ref as appropriate) instead ofOnyxUtils.get(...).
Acceptance criteria
- No references to
OnyxUtils/react-native-onyx/dist/OnyxUtilsremain in this file. - The restart check reads
GPS_DRAFT_DETAILSvia the existinguseOnyxsubscription. - On app restart, an in-progress trip still prompts the "continue trip" modal, and an orphaned background task is still stopped when there's no active trip.
Notes
This is one of several issues removing OnyxUtils.get() across the app. A separate issue will add an ESLint rule to prevent it from being reintroduced.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022087946421083935533
- Upwork Job ID: 2087946421083935533
- Last Price Increase: 2026-08-13
Activity
melvin-bot commentedon Aug 13, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mkhutornyi (
External)melvin-bot commentedon Aug 13, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022087946421083935533
mkhutornyi commentedon Aug 13, 2026
@MelvinBot submit proposal
MelvinBot commentedon Aug 13, 2026
Proposal
What is the root cause of that problem?
GPSTripStateChecker/index.native.tsxreadsGPS_DRAFT_DETAILSin its mount effect viaOnyxUtils.get(...), imported from the internal deep pathreact-native-onyx/dist/OnyxUtils. That is not a sanctioned Onyx read API and couples the component to Onyx internals. This is a React component that already subscribes to the same key viauseOnyx(ONYXKEYS.GPS_DRAFT_DETAILS), so the raw read is redundant. It only exists because the mount effect has[]deps anduseOnyxhydrates asynchronously — on first render the subscription value may not be loaded yet, so the effect can't simply trustgpsDraftDetails.What changes do you think we should make in order to solve the problem?
Serve the restart check from the existing
useOnyxsubscription, gated on its loaded status:import OnyxUtils from 'react-native-onyx/dist/OnyxUtils'line and theOnyxUtils.get(...)call.const [gpsDraftDetails, gpsDraftDetailsMetadata] = useOnyx(ONYXKEYS.GPS_DRAFT_DETAILS);'loaded', and readsgpsDraftDetails(the value thatOnyxUtils.getused to fetch). Use auseRefflag so it fires a single time even as the value changes later in the session:gpsDraftDetailsMetadata.status !== 'loaded'or the ref flag is already set; otherwise set the flag and runhandleGpsTripInProgressOnAppRestart(), readinggpsDraftDetails?.isTrackinginstead ofgpsTrip?.isTracking.gpsDraftDetailsandgpsDraftDetailsMetadata.statusto the dependency array.[]-dependencyuseEffectrather than moving into the newly gated effect.This satisfies the acceptance criteria: no
OnyxUtilsreferences remain, the restart check readsGPS_DRAFT_DETAILSthrough the existing subscription, and behavior is preserved — an in-progress trip still prompts the "continue trip" modal, and an orphaned background task is still stopped when there's no active trip. Gating onstatus === 'loaded'(rather than reading the value early) is important so we don't misread the not-yet-hydrated state as "no trip" and wrongly stop tracking.What alternative solutions did you explore? (Optional)
The repo already has
useInitialOnyxValue(useInitialOnyxValue(ONYXKEYS.GPS_DRAFT_DETAILS)), which returns the value snapshotted at the first'loaded'and never updates — a natural fit for a mount-time snapshot. I lean away from it here because it returnsundefinedboth before load and when there's genuinely no trip, so the effect still needs thestatusto safely distinguish "not loaded yet" from "no active trip" before stopping the background task. The status-gateduseOnyxapproach above makes that distinction explicit, so I'd recommend it.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/98609)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
mkhutornyi commentedon Aug 13, 2026
@MelvinBot's proposal looks good.
🎀 👀 🎀 C+ reviewed
melvin-bot commentedon Aug 13, 2026
Triggered auto assignment to @amyevans, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
MelvinBot commentedon Aug 13, 2026
🎉 Thanks for the review! Glad the proposal looks good.
Whenever you're ready for me to open the draft PR, reply with
@MelvinBot implement thisand I'll implement the status-gateduseOnyxchange (remove theOnyxUtils.get()deep-import read, serve the restart check from the existing subscription oncestatus === 'loaded', and keep the unmount cleanup on its own[]effect).amyevans commentedon Aug 14, 2026
👍 , feel free to proceed with Melvin on the PR @mkhutornyi!
mkhutornyi commentedon Aug 15, 2026
@MelvinBot implement this
9 remaining items
mkhutornyi commentedon Aug 21, 2026
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment:
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Refactor PR. No need regression test
melvin-bot commentedon Aug 26, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Aug 26, 2026
Payment Summary
Resolving PRs:
Remove OnyxUtils.get() from GPSTripStateChecker (use useOnyx) #98703
Reviewer: @mkhutornyi owed $250 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Aug 27, 2026
Payment Summary
Contributor+: @mkhutornyi due $250 via NewDot
trjExpensify commentedon Sep 17, 2026
approved $250 for @mkhutornyi