Skip to content

Commit bb6f7f3

Browse files
authored
Merge pull request Expensify#82467 from callstack-internal/feature/remove-canBeMissing
[No QA] Bump Onyx to 3.0.38 / Remove canBeMissing usage from the codebase
2 parents cfcd45a + 2f8904c commit bb6f7f3

916 files changed

Lines changed: 2672 additions & 2991 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ This is a checklist for PR authors. Please make sure to complete all tasks and c
8686
- [ ] iOS: mWeb Safari
8787
- [ ] MacOS: Chrome / Safari
8888
- [ ] 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)
89-
- [ ] I verified there are no new alerts related to the `canBeMissing` param for `useOnyx`
9089
- [ ] I followed proper code patterns (see [Reviewing the code](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md#reviewing-the-code))
9190
- [ ] 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`)
9291
- [ ] I verified that comments were added to code that is not self explanatory

contributingGuides/REVIEWER_CHECKLIST.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
- [ ] iOS: mWeb Safari
1818
- [ ] MacOS: Chrome / Safari
1919
- [ ] 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
20-
- [ ] I verified there are no new alerts related to the `canBeMissing` param for `useOnyx`
2120
- [ ] I verified proper code patterns were followed (see [Reviewing the code](https://github.com/Expensify/App/blob/main/contributingGuides/PR_REVIEW_GUIDELINES.md#reviewing-the-code))
2221
- [ ] 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`).
2322
- [ ] I verified that comments were added to code that is not self explanatory

contributingGuides/philosophies/ONYX-DATA-MANAGEMENT.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ This is how the application manages all the data stored in Onyx.
99
- **Actions** - The files stored in `/src/libs/actions`
1010
- **Derived Values** - Special Onyx keys containing values computed from other Onyx values
1111
- **Collections** - Multiple related data objects stored as individual keys with IDs
12-
- **canBeMissing** - Parameter indicating whether a component expects Onyx data to be present
1312

1413
## Rules
1514
### - Actions MUST be the only means to write or read data from the server
@@ -126,24 +125,3 @@ compute: ([reports, personalDetails]) => {
126125
- Explain the purpose and dependencies
127126
- Document any special cases or performance considerations
128127
- Include type annotations for better developer experience
129-
130-
## canBeMissing Parameter
131-
132-
The `canBeMissing` parameter indicates whether a component connecting to Onyx expects the data to be present or if it can handle missing data gracefully.
133-
134-
### - Components MUST use the `canBeMissing` parameter appropriately
135-
This parameter was added because in some places we are assuming some data will be there, but actually we never load it, which leads to hard to debug bugs.
136-
137-
The linter error exists until we add the param to all callers. Once that happens we can make the param mandatory and remove the linter.
138-
139-
### - `canBeMissing` SHOULD be set to `false` when data is guaranteed to be present
140-
The main criteria for setting `canBeMissing` to `false`:
141-
142-
- **Data is always loaded before component renders**: If the data is always ensured to be loaded before this component renders, then `canBeMissing` SHOULD be set to `false`
143-
- **Always returned by OpenApp**: Any data that is always returned by `OpenApp` used in a component where we have a user (so not in the homepage for example) will have `canBeMissing` set to `false`
144-
- **User always has data**: Maybe we always try to load a piece of data, but the data can be missing/empty, in this case `canBeMissing` would be set to `false`
145-
146-
### - `canBeMissing` SHOULD be set to `true` for potentially missing data
147-
If neither of the above conditions apply, then the param SHOULD probably be `true`, but additionally we MUST make sure that the code using the data manages correctly the fact that the data might be missing.
148-
149-
Context: [Slack discussion](https://expensify.slack.com/archives/C03TQ48KC/p1741208342513379)

eslint.changed.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ const config = defineConfig([
4343
rules: {
4444
'@typescript-eslint/no-deprecated': 'error',
4545
'rulesdir/no-default-id-values': 'error',
46-
'rulesdir/provide-canBeMissing-in-useOnyx': 'error',
4746
'rulesdir/no-unstable-hook-defaults': 'error',
4847
'no-restricted-syntax': [
4948
'error',

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
"react-native-localize": "^3.5.4",
181181
"react-native-nitro-modules": "0.29.4",
182182
"react-native-nitro-sqlite": "9.2.0",
183-
"react-native-onyx": "3.0.35",
183+
"react-native-onyx": "3.0.38",
184184
"react-native-pager-view": "8.0.0",
185185
"react-native-pdf": "7.0.2",
186186
"react-native-performance": "^6.0.0",

src/Expensify.tsx

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ import {hasAuthToken} from './libs/actions/Session';
3333
import * as User from './libs/actions/User';
3434
import * as ActiveClientManager from './libs/ActiveClientManager';
3535
import {isSafari} from './libs/Browser';
36-
import * as Environment from './libs/Environment/Environment';
3736
import FS from './libs/Fullstory';
38-
import Growl, {growlRef} from './libs/Growl';
37+
import {growlRef} from './libs/Growl';
3938
import Log from './libs/Log';
4039
import migrateOnyx from './libs/migrateOnyx';
4140
import Navigation from './libs/Navigation/Navigation';
@@ -62,13 +61,6 @@ Onyx.registerLogger(({level, message, parameters}) => {
6261
if (level === 'alert') {
6362
Log.alert(message, parameters);
6463
console.error(message);
65-
66-
// useOnyx() calls with "canBeMissing" config set to false will display a visual alert in dev environment
67-
// when they don't return data.
68-
const shouldShowAlert = typeof parameters === 'object' && !Array.isArray(parameters) && 'showAlert' in parameters && 'key' in parameters;
69-
if (Environment.isDevelopment() && shouldShowAlert) {
70-
Growl.error(`${message} Key: ${parameters.key as string}`, 10000);
71-
}
7264
} else if (level === 'hmmm') {
7365
Log.hmmm(message, parameters);
7466
} else {
@@ -106,24 +98,24 @@ function Expensify() {
10698
const {setSplashScreenState} = useSplashScreenActions();
10799
const [hasAttemptedToOpenPublicRoom, setAttemptedToOpenPublicRoom] = useState(false);
108100
const {translate, preferredLocale} = useLocalize();
109-
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
110-
const [session, sessionMetadata] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
111-
const [lastRoute] = useOnyx(ONYXKEYS.LAST_ROUTE, {canBeMissing: true});
112-
const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA, {canBeMissing: true});
113-
const [isCheckingPublicRoom = true] = useOnyx(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, {initWithStoredValues: false, canBeMissing: true});
114-
const [updateAvailable] = useOnyx(ONYXKEYS.UPDATE_AVAILABLE, {initWithStoredValues: false, canBeMissing: true});
115-
const [updateRequired] = useOnyx(ONYXKEYS.UPDATE_REQUIRED, {initWithStoredValues: false, canBeMissing: true});
116-
const [isSidebarLoaded] = useOnyx(ONYXKEYS.IS_SIDEBAR_LOADED, {canBeMissing: true});
117-
const [screenShareRequest] = useOnyx(ONYXKEYS.SCREEN_SHARE_REQUEST, {canBeMissing: true});
118-
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: true});
119-
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false});
120-
const [hasLoadedApp] = useOnyx(ONYXKEYS.HAS_LOADED_APP, {canBeMissing: true});
121-
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true});
101+
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
102+
const [session, sessionMetadata] = useOnyx(ONYXKEYS.SESSION);
103+
const [lastRoute] = useOnyx(ONYXKEYS.LAST_ROUTE);
104+
const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA);
105+
const [isCheckingPublicRoom = true] = useOnyx(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, {initWithStoredValues: false});
106+
const [updateAvailable] = useOnyx(ONYXKEYS.UPDATE_AVAILABLE, {initWithStoredValues: false});
107+
const [updateRequired] = useOnyx(ONYXKEYS.UPDATE_REQUIRED, {initWithStoredValues: false});
108+
const [isSidebarLoaded] = useOnyx(ONYXKEYS.IS_SIDEBAR_LOADED);
109+
const [screenShareRequest] = useOnyx(ONYXKEYS.SCREEN_SHARE_REQUEST);
110+
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH);
111+
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
112+
const [hasLoadedApp] = useOnyx(ONYXKEYS.HAS_LOADED_APP);
113+
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
122114
const {isOffline} = useNetwork();
123-
const [stashedCredentials = CONST.EMPTY_OBJECT] = useOnyx(ONYXKEYS.STASHED_CREDENTIALS, {canBeMissing: true});
124-
const [stashedSession] = useOnyx(ONYXKEYS.STASHED_SESSION, {canBeMissing: true});
125-
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});
126-
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID, {canBeMissing: true});
115+
const [stashedCredentials = CONST.EMPTY_OBJECT] = useOnyx(ONYXKEYS.STASHED_CREDENTIALS);
116+
const [stashedSession] = useOnyx(ONYXKEYS.STASHED_SESSION);
117+
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
118+
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
127119

128120
useDebugShortcut();
129121
usePriorityMode();

src/HybridAppHandler.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import isLoadingOnyxValue from './types/utils/isLoadingOnyxValue';
1414
function HybridAppHandler() {
1515
const {splashScreenState} = useSplashScreenState();
1616
const {setSplashScreenState} = useSplashScreenActions();
17-
const [tryNewDot, tryNewDotMetadata] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {canBeMissing: true});
17+
const [tryNewDot, tryNewDotMetadata] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT);
1818
const isLoadingTryNewDot = isLoadingOnyxValue(tryNewDotMetadata);
1919

2020
const finalizeTransitionFromOldDot = useCallback(

src/components/AccountSwitcher.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
4747
const {localeCompare, translate, formatPhoneNumber} = useLocalize();
4848
const {isOffline} = useNetwork();
4949
const {shouldUseNarrowLayout} = useResponsiveLayout();
50-
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
51-
const [accountID] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false, selector: accountIDSelector});
52-
const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED, {canBeMissing: true});
53-
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS, {canBeMissing: true});
54-
const [stashedCredentials = CONST.EMPTY_OBJECT] = useOnyx(ONYXKEYS.STASHED_CREDENTIALS, {canBeMissing: true});
55-
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
56-
const [stashedSession] = useOnyx(ONYXKEYS.STASHED_SESSION, {canBeMissing: true});
57-
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
50+
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
51+
const [accountID] = useOnyx(ONYXKEYS.SESSION, {selector: accountIDSelector});
52+
const [isDebugModeEnabled] = useOnyx(ONYXKEYS.IS_DEBUG_MODE_ENABLED);
53+
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS);
54+
const [stashedCredentials = CONST.EMPTY_OBJECT] = useOnyx(ONYXKEYS.STASHED_CREDENTIALS);
55+
const [session] = useOnyx(ONYXKEYS.SESSION);
56+
const [stashedSession] = useOnyx(ONYXKEYS.STASHED_SESSION);
57+
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
5858

5959
const buttonRef = useRef<HTMLDivElement>(null);
6060
const {windowHeight} = useWindowDimensions();

src/components/AddPaymentCard/PaymentCardForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function PaymentCardForm({
126126
currencySelectorRoute,
127127
}: PaymentCardFormProps) {
128128
const styles = useThemeStyles();
129-
const [data, metadata] = useOnyx(ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM, {canBeMissing: true});
129+
const [data, metadata] = useOnyx(ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM);
130130

131131
const {translate} = useLocalize();
132132
const route = useRoute();

0 commit comments

Comments
 (0)