Skip to content

Commit 831c8cf

Browse files
authored
Merge pull request Expensify#90099 from dukenv0307/fix/66407-part-10
update getUpdateMoneyRequestParams to use isOffline from useOnyx
2 parents 29c207a + b4b6354 commit 831c8cf

8 files changed

Lines changed: 357 additions & 2 deletions

File tree

src/components/ReportActionItem/MoneyRequestView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ function MoneyRequestView({
561561
currentUserEmailParam,
562562
isASAPSubmitBetaEnabled,
563563
parentReportNextStep,
564+
isOffline,
564565
delegateAccountID,
565566
});
566567
};

src/hooks/useTransactionInlineEdit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {isExpenseUnreported, isPerDiemRequest} from '@libs/TransactionUtils';
2525
import CONST from '@src/CONST';
2626
import ONYXKEYS from '@src/ONYXKEYS';
2727
import type {ReportAction, ReportActions} from '@src/types/onyx';
28+
import useNetwork from './useNetwork';
2829
import useOnyx from './useOnyx';
2930
import usePolicyForMovingExpenses from './usePolicyForMovingExpenses';
3031
import usePolicyForTransaction from './usePolicyForTransaction';
@@ -129,6 +130,8 @@ function useTransactionInlineEdit({transactionID, hash, linkedReportAction}: Use
129130
const isPerDiem = isPerDiemRequest(transaction);
130131
const {shouldSelectPolicy} = usePolicyForMovingExpenses(isPerDiem);
131132

133+
const {isOffline} = useNetwork();
134+
132135
const permissions = getTransactionEditPermissions({
133136
transaction,
134137
parentReportAction,
@@ -159,6 +162,7 @@ function useTransactionInlineEdit({transactionID, hash, linkedReportAction}: Use
159162
policyRecentlyUsedCategories,
160163
policyRecentlyUsedTags,
161164
parentReportNextStep,
165+
isOffline,
162166
isSelfTourViewed: guidedSetupAndTourStatus?.isSelfTourViewed ?? false,
163167
hasCompletedGuidedSetupFlow: guidedSetupAndTourStatus?.hasCompletedGuidedSetupFlow ?? false,
164168
};

src/libs/actions/IOU/UpdateMoneyRequest.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ function updateMoneyRequestReimbursable({
261261
currentUserEmailParam,
262262
isASAPSubmitBetaEnabled,
263263
parentReportNextStep,
264+
isOffline,
264265
delegateAccountID,
265266
}: {
266267
transactionID: string | undefined;
@@ -274,6 +275,7 @@ function updateMoneyRequestReimbursable({
274275
currentUserEmailParam: string;
275276
isASAPSubmitBetaEnabled: boolean;
276277
parentReportNextStep: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
278+
isOffline: boolean;
277279
delegateAccountID: number | undefined;
278280
}) {
279281
if (!transactionID || !transactionThreadReport?.reportID) {
@@ -296,6 +298,7 @@ function updateMoneyRequestReimbursable({
296298
currentUserEmailParam,
297299
isASAPSubmitBetaEnabled,
298300
iouReportNextStep: parentReportNextStep,
301+
isOffline,
299302
delegateAccountID,
300303
});
301304
API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_REIMBURSABLE, params, onyxData);
@@ -314,6 +317,7 @@ function updateMoneyRequestMerchant({
314317
currentUserEmailParam,
315318
isASAPSubmitBetaEnabled,
316319
parentReportNextStep,
320+
isOffline,
317321
hash,
318322
delegateAccountID,
319323
}: {
@@ -328,6 +332,7 @@ function updateMoneyRequestMerchant({
328332
currentUserEmailParam: string;
329333
isASAPSubmitBetaEnabled: boolean;
330334
parentReportNextStep: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
335+
isOffline: boolean;
331336
hash?: number;
332337
delegateAccountID: number | undefined;
333338
}) {
@@ -353,6 +358,7 @@ function updateMoneyRequestMerchant({
353358
currentUserEmailParam,
354359
isASAPSubmitBetaEnabled,
355360
iouReportNextStep: parentReportNextStep,
361+
isOffline,
356362
hash,
357363
delegateAccountID,
358364
});
@@ -375,6 +381,7 @@ function updateMoneyRequestAttendees({
375381
currentUserEmailParam,
376382
isASAPSubmitBetaEnabled,
377383
parentReportNextStep,
384+
isOffline,
378385
delegateAccountID,
379386
}: {
380387
transactionID: string;
@@ -389,6 +396,7 @@ function updateMoneyRequestAttendees({
389396
currentUserEmailParam: string;
390397
isASAPSubmitBetaEnabled: boolean;
391398
parentReportNextStep: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
399+
isOffline: boolean;
392400
delegateAccountID: number | undefined;
393401
}) {
394402
const transactionChanges: TransactionChanges = {
@@ -409,6 +417,7 @@ function updateMoneyRequestAttendees({
409417
currentUserEmailParam,
410418
isASAPSubmitBetaEnabled,
411419
iouReportNextStep: parentReportNextStep,
420+
isOffline,
412421
delegateAccountID,
413422
});
414423
const {params, onyxData} = data;
@@ -510,6 +519,7 @@ type UpdateMoneyRequestTagParams = {
510519
isASAPSubmitBetaEnabled: boolean;
511520
hash?: number;
512521
parentReportNextStep: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
522+
isOffline: boolean;
513523
delegateAccountID: number | undefined;
514524
};
515525

@@ -528,6 +538,7 @@ function updateMoneyRequestTag({
528538
isASAPSubmitBetaEnabled,
529539
hash,
530540
parentReportNextStep,
541+
isOffline,
531542
delegateAccountID,
532543
}: UpdateMoneyRequestTagParams) {
533544
const transactionChanges: TransactionChanges = {
@@ -549,6 +560,7 @@ function updateMoneyRequestTag({
549560
currentUserEmailParam,
550561
isASAPSubmitBetaEnabled,
551562
iouReportNextStep: parentReportNextStep,
563+
isOffline,
552564
delegateAccountID,
553565
});
554566
API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_TAG, params, onyxData);

src/libs/actions/TransactionInlineEdit.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type {ValueOf} from 'type-fest';
1010
import {isCategoryMissing} from '@libs/CategoryUtils';
1111
import {convertToBackendAmount, getCurrencyDecimals} from '@libs/CurrencyUtils';
1212
import {isValidMerchant, isValidMoneyRequestAmount} from '@libs/MoneyRequestUtils';
13-
import {getIsOffline} from '@libs/NetworkState';
1413
import {hasEnabledOptions} from '@libs/OptionsListUtils';
1514
import Permissions from '@libs/Permissions';
1615
import {getTagLists, isMultiLevelTags} from '@libs/PolicyUtils';
@@ -181,6 +180,7 @@ type GetIouParamsInput = {
181180

182181
type TransactionInlineEditParams = GetIouParamsInput & {
183182
hash: number | undefined;
183+
isOffline: boolean;
184184
};
185185

186186
/**
@@ -283,7 +283,7 @@ function editTransactionDateInline(params: TransactionInlineEditParams, newDate:
283283
value: newDate,
284284
transactions: allTransactions,
285285
transactionViolations: allTransactionViolations,
286-
isOffline: getIsOffline(),
286+
isOffline: params.isOffline,
287287
hash: params.hash,
288288
});
289289
}
@@ -301,6 +301,7 @@ function editTransactionMerchantInline(params: TransactionInlineEditParams, newM
301301
...iouParams,
302302
value: newMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT,
303303
hash: params.hash,
304+
isOffline: params.isOffline,
304305
});
305306
}
306307

@@ -365,6 +366,7 @@ function editTransactionTagInline(params: TransactionInlineEditParams, newTag: s
365366
tag: newTag,
366367
policyRecentlyUsedTags: iouParams.policyRecentlyUsedTags,
367368
hash: params.hash,
369+
isOffline: params.isOffline,
368370
});
369371
}
370372

src/pages/iou/request/step/IOURequestStepAttendees.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, {useCallback, useState} from 'react';
33
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
44
import useDelegateAccountID from '@hooks/useDelegateAccountID';
55
import useLocalize from '@hooks/useLocalize';
6+
import useNetwork from '@hooks/useNetwork';
67
import useOnyx from '@hooks/useOnyx';
78
import usePermissions from '@hooks/usePermissions';
89
import usePrevious from '@hooks/usePrevious';
@@ -52,6 +53,7 @@ function IOURequestStepAttendees({
5253
const delegateAccountID = useDelegateAccountID();
5354
const {isBetaEnabled} = usePermissions();
5455
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
56+
const {isOffline} = useNetwork();
5557

5658
const saveAttendees = useCallback(() => {
5759
if (attendees.length <= 0) {
@@ -72,6 +74,7 @@ function IOURequestStepAttendees({
7274
currentUserEmailParam,
7375
isASAPSubmitBetaEnabled,
7476
parentReportNextStep,
77+
isOffline,
7578
delegateAccountID,
7679
});
7780
} else {
@@ -96,6 +99,7 @@ function IOURequestStepAttendees({
9699
currentUserEmailParam,
97100
isASAPSubmitBetaEnabled,
98101
parentReportNextStep,
102+
isOffline,
99103
delegateAccountID,
100104
]);
101105

src/pages/iou/request/step/IOURequestStepMerchant.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
99
import useDelegateAccountID from '@hooks/useDelegateAccountID';
1010
import useDiscardChangesConfirmation from '@hooks/useDiscardChangesConfirmation';
1111
import useLocalize from '@hooks/useLocalize';
12+
import useNetwork from '@hooks/useNetwork';
1213
import useOnyx from '@hooks/useOnyx';
1314
import usePermissions from '@hooks/usePermissions';
1415
import usePolicy from '@hooks/usePolicy';
@@ -73,6 +74,7 @@ function IOURequestStepMerchant({
7374
const currentUserEmailParam = currentUserPersonalDetails.login ?? '';
7475
const {isBetaEnabled} = usePermissions();
7576
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
77+
const {isOffline} = useNetwork();
7678

7779
const isMerchantRequired = isPolicyExpenseChat(report) || isExpenseRequest(report) || transaction?.participants?.some((participant) => !!participant.isPolicyExpenseChat);
7880

@@ -144,6 +146,7 @@ function IOURequestStepMerchant({
144146
currentUserEmailParam,
145147
isASAPSubmitBetaEnabled,
146148
parentReportNextStep,
149+
isOffline,
147150
delegateAccountID,
148151
});
149152
} else {

src/pages/iou/request/step/IOURequestStepTag.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
99
import useDelegateAccountID from '@hooks/useDelegateAccountID';
1010
import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
1111
import useLocalize from '@hooks/useLocalize';
12+
import useNetwork from '@hooks/useNetwork';
1213
import useOnyx from '@hooks/useOnyx';
1314
import usePermissions from '@hooks/usePermissions';
1415
import usePolicyForMovingExpenses from '@hooks/usePolicyForMovingExpenses';
@@ -76,6 +77,7 @@ function IOURequestStepTag({
7677
const delegateAccountID = useDelegateAccountID();
7778
const {isBetaEnabled} = usePermissions();
7879
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
80+
const {isOffline} = useNetwork();
7981

8082
const styles = useThemeStyles();
8183
const illustrations = useMemoizedLazyIllustrations(['EmptyStateExpenses']);
@@ -159,6 +161,7 @@ function IOURequestStepTag({
159161
isASAPSubmitBetaEnabled,
160162
hash: currentSearchHash,
161163
parentReportNextStep,
164+
isOffline,
162165
delegateAccountID,
163166
});
164167
navigateBack();

0 commit comments

Comments
 (0)