Skip to content

Commit 29ce13f

Browse files
authored
Merge pull request #20 from margelo/@chrispader/onyx-2-0-43-null-undefined-changes
Onyx Bump 2.0.47: `null` -> `undefined` changes
2 parents 9957f98 + 2e70512 commit 29ce13f

File tree

83 files changed

+577
-581
lines changed

Some content is hidden

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

83 files changed

+577
-581
lines changed

package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"react-native-linear-gradient": "^2.8.1",
155155
"react-native-localize": "^2.2.6",
156156
"react-native-modal": "^13.0.0",
157-
"react-native-onyx": "2.0.41",
157+
"react-native-onyx": "2.0.47",
158158
"react-native-pager-view": "6.2.3",
159159
"react-native-pdf": "6.7.3",
160160
"react-native-performance": "^5.1.0",

src/components/AvatarWithDisplayName.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type AvatarWithDisplayNameProps = AvatarWithDisplayNamePropsWithOnyx & {
3434
report: OnyxEntry<Report>;
3535

3636
/** The policy which the user has access to and which the report is tied to */
37-
policy?: OnyxEntry<Policy>;
37+
policy?: OnyxEntry<Policy> | null;
3838

3939
/** The size of the avatar */
4040
size?: ValueOf<typeof CONST.AVATAR_SIZE>;

src/components/HeaderWithBackButton/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function HeaderWithBackButton({
3030
onCloseButtonPress = () => Navigation.dismissModal(),
3131
onDownloadButtonPress = () => {},
3232
onThreeDotsButtonPress = () => {},
33-
report = null,
33+
report,
3434
policy,
3535
policyAvatar,
3636
shouldShowReportAvatarWithDisplay = false,

src/components/HeaderWithBackButton/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ type HeaderWithBackButtonProps = Partial<ChildrenProps> & {
102102
report?: OnyxEntry<Report>;
103103

104104
/** The report's policy, if we're showing the details for a report and need info about it for AvatarWithDisplay */
105-
policy?: OnyxEntry<Policy>;
105+
policy?: OnyxEntry<Policy> | null;
106106

107107
/** Single execution function to prevent concurrent navigation actions */
108108
singleExecution?: <T extends unknown[]>(action: Action<T>) => Action<T>;

src/components/KYCWall/BaseKYCWall.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function KYCWall({
166166

167167
transferBalanceButtonRef.current = targetElement;
168168

169-
const isExpenseReport = ReportUtils.isExpenseReport(iouReport ?? null);
169+
const isExpenseReport = ReportUtils.isExpenseReport(iouReport);
170170
const paymentCardList = fundList ?? {};
171171

172172
// Check to see if user has a valid payment method on file and display the add payment popover if they don't

src/components/LHNOptionsList/LHNOptionsList.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ function LHNOptionsList({
106106
*/
107107
const renderItem = useCallback(
108108
({item: reportID}: RenderItemProps): ReactElement => {
109-
const itemFullReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] ?? null;
110-
const itemReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? null;
111-
const itemParentReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${itemFullReport?.parentReportID}`] ?? null;
112-
const itemParentReportAction = itemParentReportActions?.[itemFullReport?.parentReportActionID ?? ''] ?? null;
113-
const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${itemFullReport?.policyID}`] ?? null;
109+
const itemFullReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
110+
const itemReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`];
111+
const itemParentReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${itemFullReport?.parentReportID}`];
112+
const itemParentReportAction = itemParentReportActions?.[itemFullReport?.parentReportActionID ?? ''];
113+
const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${itemFullReport?.policyID}`];
114114
const transactionID = itemParentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? itemParentReportAction.originalMessage.IOUTransactionID ?? '' : '';
115-
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? null;
115+
const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
116116
const hasDraftComment = DraftCommentUtils.isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]);
117117
const sortedReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(itemReportActions);
118118
const lastReportAction = sortedReportActions[0];

src/components/LHNOptionsList/OptionRowLHN.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
123123
const formattedDate = DateUtils.getStatusUntilDate(statusClearAfterDate);
124124
const statusContent = formattedDate ? `${statusText ? `${statusText} ` : ''}(${formattedDate})` : statusText;
125125
const report = ReportUtils.getReport(optionItem.reportID ?? '');
126-
const isStatusVisible = !!emojiCode && ReportUtils.isOneOnOneChat(!isEmptyObject(report) ? report : null);
126+
const isStatusVisible = !!emojiCode && ReportUtils.isOneOnOneChat(!isEmptyObject(report) ? report : undefined);
127127

128128
const isGroupChat = ReportUtils.isGroupChat(optionItem) || ReportUtils.isDeprecatedGroupDM(optionItem);
129129

src/components/LHNOptionsList/OptionRowLHNData.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function OptionRowLHNData({
3535

3636
const optionItemRef = useRef<OptionData>();
3737

38-
const shouldDisplayViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction ?? null);
38+
const shouldDisplayViolations = canUseViolations && ReportUtils.shouldDisplayTransactionThreadViolations(fullReport, transactionViolations, parentReportAction);
3939

4040
const optionItem = useMemo(() => {
4141
// Note: ideally we'd have this as a dependent selector in onyx!

src/components/MoneyReportHeader.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type MoneyReportHeaderProps = {
3535
report: OnyxTypes.Report;
3636

3737
/** The policy tied to the expense report */
38-
policy: OnyxEntry<OnyxTypes.Policy>;
38+
policy: OnyxEntry<OnyxTypes.Policy> | null;
3939

4040
/** Array of report actions for the report */
4141
reportActions: OnyxTypes.ReportAction[];

src/components/MoneyRequestConfirmationList.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps &
133133
selectedParticipants: Participant[];
134134

135135
/** Payee of the expense with login */
136-
payeePersonalDetails?: OnyxEntry<OnyxTypes.PersonalDetails>;
136+
payeePersonalDetails?: OnyxEntry<OnyxTypes.PersonalDetails> | null;
137137

138138
/** Should the list be read only, and not editable? */
139139
isReadOnly?: boolean;
@@ -184,7 +184,7 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps &
184184
type MoneyRequestConfirmationListItem = Participant | ReportUtils.OptionData;
185185

186186
function MoneyRequestConfirmationList({
187-
transaction = null,
187+
transaction,
188188
onSendMoney,
189189
onConfirm,
190190
iouType = CONST.IOU.TYPE.SUBMIT,
@@ -709,7 +709,7 @@ function MoneyRequestConfirmationList({
709709
if (selectedParticipants.length === 0) {
710710
return;
711711
}
712-
if (!isEditingSplitBill && isMerchantRequired && (isMerchantEmpty || (shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction ?? null)))) {
712+
if (!isEditingSplitBill && isMerchantRequired && (isMerchantEmpty || (shouldDisplayFieldError && TransactionUtils.isMerchantMissing(transaction)))) {
713713
setFormError('iou.error.invalidMerchant');
714714
return;
715715
}
@@ -739,7 +739,7 @@ function MoneyRequestConfirmationList({
739739
return;
740740
}
741741

742-
if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction ?? null)) {
742+
if (isEditingSplitBill && TransactionUtils.areRequiredFieldsEmpty(transaction)) {
743743
setDidConfirmSplit(true);
744744
setFormError('iou.error.genericSmartscanFailureMessage');
745745
return;
@@ -861,8 +861,8 @@ function MoneyRequestConfirmationList({
861861
style={[styles.moneyRequestMenuItem, styles.mt2]}
862862
titleStyle={styles.moneyRequestConfirmationAmount}
863863
disabled={didConfirm}
864-
brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ?? null) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
865-
errorText={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction ?? null) ? translate('common.error.enterAmount') : ''}
864+
brickRoadIndicator={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
865+
errorText={shouldDisplayFieldError && TransactionUtils.isAmountMissing(transaction) ? translate('common.error.enterAmount') : ''}
866866
/>
867867
),
868868
shouldShow: shouldShowSmartScanFields,
@@ -1096,7 +1096,7 @@ function MoneyRequestConfirmationList({
10961096
isThumbnail,
10971097
fileExtension,
10981098
isLocalFile,
1099-
} = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction ?? null, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI);
1099+
} = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI);
11001100

11011101
const resolvedThumbnail = isLocalFile ? receiptThumbnail : tryResolveUrlFromApiRoot(receiptThumbnail ?? '');
11021102
const resolvedReceiptImage = isLocalFile ? receiptImage : tryResolveUrlFromApiRoot(receiptImage ?? '');

src/components/MoneyRequestHeader.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ type MoneyRequestHeaderProps = {
3535
report: Report;
3636

3737
/** The policy which the report is tied to */
38-
policy: OnyxEntry<Policy>;
38+
policy: OnyxEntry<Policy> | null;
3939

4040
/** The report action the transaction is tied to from the parent report */
41-
parentReportAction: OnyxEntry<ReportAction>;
41+
parentReportAction: OnyxEntry<ReportAction> | null;
4242

4343
/** Whether we should display the header as in narrow layout */
4444
shouldUseNarrowLayout?: boolean;

src/components/ShowContextMenuContext.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ type ShowContextMenuContextProps = {
1919

2020
const ShowContextMenuContext = createContext<ShowContextMenuContextProps>({
2121
anchor: null,
22-
report: null,
23-
action: null,
24-
transactionThreadReport: null,
22+
report: undefined,
23+
action: undefined,
24+
transactionThreadReport: undefined,
2525
checkIfContextMenuActive: () => {},
2626
});
2727

src/languages/types.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {OnyxEntry} from 'react-native-onyx';
2-
import type {ReportAction} from '@src/types/onyx';
2+
import type {OnyxInputOrEntry, ReportAction} from '@src/types/onyx';
33
import type {Unit} from '@src/types/onyx/Policy';
44
import type en from './en';
55

@@ -41,15 +41,15 @@ type LocalTimeParams = {
4141
};
4242

4343
type EditActionParams = {
44-
action: OnyxEntry<ReportAction>;
44+
action: OnyxInputOrEntry<ReportAction>;
4545
};
4646

4747
type DeleteActionParams = {
48-
action: OnyxEntry<ReportAction>;
48+
action: OnyxInputOrEntry<ReportAction>;
4949
};
5050

5151
type DeleteConfirmationParams = {
52-
action: OnyxEntry<ReportAction>;
52+
action: OnyxInputOrEntry<ReportAction>;
5353
};
5454

5555
type BeginningOfChatHistoryDomainRoomPartOneParams = {

src/libs/DistanceRequestUtils.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider';
44
import type {RateAndUnit} from '@src/CONST';
55
import CONST from '@src/CONST';
66
import ONYXKEYS from '@src/ONYXKEYS';
7-
import type {LastSelectedDistanceRates, Report} from '@src/types/onyx';
7+
import type {LastSelectedDistanceRates, OnyxInputOrEntry, Report} from '@src/types/onyx';
88
import type {Unit} from '@src/types/onyx/Policy';
99
import type Policy from '@src/types/onyx/Policy';
1010
import type {EmptyObject} from '@src/types/utils/EmptyObject';
@@ -39,7 +39,7 @@ Onyx.connect({
3939
const METERS_TO_KM = 0.001; // 1 kilometer is 1000 meters
4040
const METERS_TO_MILES = 0.000621371; // There are approximately 0.000621371 miles in a meter
4141

42-
function getMileageRates(policy: OnyxEntry<Policy>, includeDisabledRates = false): Record<string, MileageRate> {
42+
function getMileageRates(policy: OnyxInputOrEntry<Policy>, includeDisabledRates = false): Record<string, MileageRate> {
4343
const mileageRates: Record<string, MileageRate> = {};
4444

4545
if (!policy || !policy?.customUnits) {
@@ -78,14 +78,14 @@ function getMileageRates(policy: OnyxEntry<Policy>, includeDisabledRates = false
7878
* @returns [currency] - The currency associated with the rate.
7979
* @returns [unit] - The unit of measurement for the distance.
8080
*/
81-
function getDefaultMileageRate(policy: OnyxEntry<Policy> | EmptyObject): MileageRate | null {
81+
function getDefaultMileageRate(policy: OnyxInputOrEntry<Policy> | EmptyObject): MileageRate | undefined {
8282
if (isEmptyObject(policy) || !policy?.customUnits) {
83-
return null;
83+
return undefined;
8484
}
8585

8686
const distanceUnit = PolicyUtils.getCustomUnit(policy);
8787
if (!distanceUnit?.rates) {
88-
return null;
88+
return;
8989
}
9090
const mileageRates = getMileageRates(policy);
9191

@@ -252,8 +252,8 @@ function convertToDistanceInMeters(distance: number, unit: Unit): number {
252252
* Returns custom unit rate ID for the distance transaction
253253
*/
254254
function getCustomUnitRateID(reportID: string) {
255-
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] ?? null;
256-
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`] ?? null;
255+
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`];
256+
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`];
257257
const policy = PolicyUtils.getPolicy(report?.policyID ?? parentReport?.policyID ?? '');
258258
let customUnitRateID: string = CONST.CUSTOM_UNITS.FAKE_P2P_ID;
259259

src/libs/IOUUtils.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type {OnyxEntry} from 'react-native-onyx';
21
import type {IOUAction, IOUType} from '@src/CONST';
32
import CONST from '@src/CONST';
43
import ROUTES from '@src/ROUTES';
5-
import type {Report, Transaction} from '@src/types/onyx';
4+
import type {OnyxInputOrEntry, Report, Transaction} from '@src/types/onyx';
65
import type {IOURequestType} from './actions/IOU';
76
import * as CurrencyUtils from './CurrencyUtils';
87
import Navigation from './Navigation/Navigation';
@@ -60,7 +59,7 @@ function calculateAmount(numberOfParticipants: number, total: number, currency:
6059
* @param isDeleting - whether the user is deleting the expense
6160
* @param isUpdating - whether the user is updating the expense
6261
*/
63-
function updateIOUOwnerAndTotal<TReport extends OnyxEntry<Report>>(
62+
function updateIOUOwnerAndTotal<TReport extends OnyxInputOrEntry<Report>>(
6463
iouReport: TReport,
6564
actorAccountID: number,
6665
amount: number,

src/libs/Navigation/AppNavigator/AuthScreens.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Onyx.connect({
127127

128128
Onyx.connect({
129129
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
130-
callback: (value: OnyxEntry<number>) => {
130+
callback: (value) => {
131131
lastUpdateIDAppliedToClient = value;
132132
},
133133
});

src/libs/Network/NetworkStore.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import CONST from '@src/CONST';
55
import ONYXKEYS from '@src/ONYXKEYS';
66
import type Credentials from '@src/types/onyx/Credentials';
77

8-
let credentials: Credentials | null = null;
9-
let authToken: string | null = null;
8+
let credentials: Credentials | null | undefined;
9+
let authToken: string | null | undefined;
1010
let authTokenType: ValueOf<typeof CONST.AUTH_TOKEN_TYPES> | null;
1111
let currentUserEmail: string | null = null;
1212
let offline = false;
@@ -62,7 +62,7 @@ Onyx.connect({
6262
Onyx.connect({
6363
key: ONYXKEYS.CREDENTIALS,
6464
callback: (val) => {
65-
credentials = val;
65+
credentials = val ?? null;
6666
checkRequiredData();
6767
},
6868
});
@@ -86,15 +86,15 @@ Onyx.connect({
8686
});
8787

8888
function getCredentials(): Credentials | null {
89-
return credentials;
89+
return credentials ?? null;
9090
}
9191

9292
function isOffline(): boolean {
9393
return offline;
9494
}
9595

9696
function getAuthToken(): string | null {
97-
return authToken;
97+
return authToken ?? null;
9898
}
9999

100100
function isSupportRequest(command: string): boolean {

0 commit comments

Comments
 (0)