Skip to content
Closed
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
2 changes: 2 additions & 0 deletions src/libs/actions/IOU/types/CreateTrackExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type CreateTrackExpenseParams = {
recentWaypoints: OnyxEntry<OnyxTypes.RecentWaypoint[]>;
betas: OnyxEntry<OnyxTypes.Beta[]>;
isSelfTourViewed: boolean;
// TODO: Make it required once we complete refactoring the trackExpense function to use hasCompletedGuidedSetupFlow. Refactor issue: https://github.com/Expensify/App/issues/66424
hasCompletedGuidedSetupFlow?: boolean;
defaultWorkspaceName?: string;
currentUserLocalCurrency: string | undefined;
previousOdometerDraft?: OnyxEntry<OnyxTypes.OdometerDraft>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type MoneyRequestStepDistanceNavigationParams = {
unit?: Unit;
personalOutputCurrency?: string;
isSelfTourViewed: boolean;
hasCompletedGuidedSetupFlow: boolean;
amountOwed: OnyxEntry<number>;
userBillingGracePeriodEnds: OnyxCollection<BillingGraceEndPeriod>;
ownerBillingGracePeriodEnd?: OnyxEntry<number>;
Expand Down Expand Up @@ -182,6 +183,7 @@ function handleMoneyRequestStepDistanceNavigation({
unit,
personalOutputCurrency,
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
Expand Down Expand Up @@ -312,6 +314,7 @@ function handleMoneyRequestStepDistanceNavigation({
recentWaypoints,
betas,
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
previousOdometerDraft,
optimisticTransactionID,
optimisticChatReportID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {hasSeenTourSelector} from '@selectors/Onboarding';
import {guidedSetupAndTourStatusSelector} from '@selectors/Onboarding';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import type {OnyxEntry} from 'react-native-onyx';
import type {LocaleContextProps} from '@components/LocaleContextProvider';
Expand Down Expand Up @@ -130,7 +130,9 @@ function useDistanceNavigation({
const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE);
const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [guidedSetupAndTourStatus] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: guidedSetupAndTourStatusSelector});
const isSelfTourViewed = !!guidedSetupAndTourStatus?.isSelfTourViewed;
const hasCompletedGuidedSetupFlow = !!guidedSetupAndTourStatus?.hasCompletedGuidedSetupFlow;
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
Expand Down Expand Up @@ -176,6 +178,7 @@ function useDistanceNavigation({
recentWaypoints,
draftTransactionIDs,
isSelfTourViewed: !!isSelfTourViewed,
hasCompletedGuidedSetupFlow,
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {hasSeenTourSelector} from '@selectors/Onboarding';
import {guidedSetupAndTourStatusSelector} from '@selectors/Onboarding';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import type {OnyxEntry} from 'react-native-onyx';
import type {LocaleContextProps} from '@components/LocaleContextProvider';
Expand Down Expand Up @@ -133,7 +133,9 @@ function useOdometerNavigation({
const [quickAction] = useOnyx(ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE);
const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [guidedSetupAndTourStatus] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: guidedSetupAndTourStatusSelector});
const isSelfTourViewed = !!guidedSetupAndTourStatus?.isSelfTourViewed;
const hasCompletedGuidedSetupFlow = !!guidedSetupAndTourStatus?.hasCompletedGuidedSetupFlow;
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
const [userBillingGracePeriodEnds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
Expand Down Expand Up @@ -183,6 +185,7 @@ function useOdometerNavigation({
personalOutputCurrency,
draftTransactionIDs,
isSelfTourViewed: !!isSelfTourViewed,
hasCompletedGuidedSetupFlow,
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import withFullTransactionOrNotFound from '@pages/iou/request/step/withFullTrans
import withWritableReportOrNotFound from '@pages/iou/request/step/withWritableReportOrNotFound';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {hasSeenTourSelector} from '@src/selectors/Onboarding';
import {guidedSetupAndTourStatusSelector} from '@src/selectors/Onboarding';
import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft';
import type {Errors} from '@src/types/onyx/OnyxCommon';
import GPSButtons from './GPSButtons';
Expand Down Expand Up @@ -68,7 +68,9 @@ function IOURequestStepDistanceGPS({
const selfDMReport = useSelfDMReport();
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [guidedSetupAndTourStatus] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: guidedSetupAndTourStatusSelector});
const isSelfTourViewed = !!guidedSetupAndTourStatus?.isSelfTourViewed;
const hasCompletedGuidedSetupFlow = !!guidedSetupAndTourStatus?.hasCompletedGuidedSetupFlow;
const [mapboxAccessToken] = useOnyx(ONYXKEYS.MAPBOX_ACCESS_TOKEN);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const reportIDToCheck = isMoneyRequestReport(report) ? report?.chatReportID : report?.reportID;
Expand Down Expand Up @@ -153,6 +155,7 @@ function IOURequestStepDistanceGPS({
personalOutputCurrency: personalPolicy?.outputCurrency,
draftTransactionIDs,
isSelfTourViewed: !!isSelfTourViewed,
hasCompletedGuidedSetupFlow,
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
Expand Down
9 changes: 5 additions & 4 deletions src/pages/iou/request/step/IOURequestStepDistanceManual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import {hasSeenTourSelector} from '@src/selectors/Onboarding';
import {guidedSetupAndTourStatusSelector} from '@src/selectors/Onboarding';
import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft';
import type Transaction from '@src/types/onyx/Transaction';
import handleMoneyRequestStepDistanceNavigation from './IOURequestStepDistance/handleMoneyRequestStepDistanceNavigation';
Expand Down Expand Up @@ -98,9 +98,9 @@ function IOURequestStepDistanceManual({
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {
selector: validTransactionDraftIDsSelector,
});
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
selector: hasSeenTourSelector,
});
const [guidedSetupAndTourStatus] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: guidedSetupAndTourStatusSelector});
const isSelfTourViewed = !!guidedSetupAndTourStatus?.isSelfTourViewed;
const hasCompletedGuidedSetupFlow = !!guidedSetupAndTourStatus?.hasCompletedGuidedSetupFlow;
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [splitDraftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`);
const [recentWaypoints] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS);
Expand Down Expand Up @@ -258,6 +258,7 @@ function IOURequestStepDistanceManual({
unit,
personalOutputCurrency: personalPolicy?.outputCurrency,
isSelfTourViewed: !!isSelfTourViewed,
hasCompletedGuidedSetupFlow,
amountOwed,
userBillingGracePeriodEnds,
ownerBillingGracePeriodEnd,
Expand Down
52 changes: 52 additions & 0 deletions tests/actions/IOU/MoneyRequestTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ describe('MoneyRequest', () => {
optimisticTransactionID: 'mock-txn-id',
optimisticChatReportID: 'mock-chat-id',
isSelfTourViewed: false,
hasCompletedGuidedSetupFlow: false,
amountOwed: 0,
draftTransactionIDs: undefined,
userBillingGracePeriodEnds: undefined,
Expand Down Expand Up @@ -1148,6 +1149,57 @@ describe('MoneyRequest', () => {
expect(capturedParticipants.length).toBeGreaterThan(0);
expect(capturedParticipants.at(0)).toMatchObject({isDisabled: false});
});

it('should forward hasCompletedGuidedSetupFlow: true to trackExpense', () => {
handleMoneyRequestStepDistanceNavigation({
...baseParams,
manualDistance: 20,
shouldSkipConfirmation: true,
iouType: CONST.IOU.TYPE.TRACK,
draftTransactionIDs: [baseParams.transactionID],
hasCompletedGuidedSetupFlow: true,
});

expect(TrackExpense.trackExpense).toHaveBeenCalledWith(
expect.objectContaining({
hasCompletedGuidedSetupFlow: true,
}),
);
});

it('should forward hasCompletedGuidedSetupFlow: false to trackExpense', () => {
handleMoneyRequestStepDistanceNavigation({
...baseParams,
manualDistance: 20,
shouldSkipConfirmation: true,
iouType: CONST.IOU.TYPE.TRACK,
draftTransactionIDs: [baseParams.transactionID],
hasCompletedGuidedSetupFlow: false,
});

expect(TrackExpense.trackExpense).toHaveBeenCalledWith(
expect.objectContaining({
hasCompletedGuidedSetupFlow: false,
}),
);
});

it('should forward hasCompletedGuidedSetupFlow to trackExpense for waypoints-based track expense', () => {
handleMoneyRequestStepDistanceNavigation({
...baseParams,
manualDistance: undefined,
shouldSkipConfirmation: true,
iouType: CONST.IOU.TYPE.TRACK,
draftTransactionIDs: [baseParams.transactionID],
hasCompletedGuidedSetupFlow: true,
});

expect(TrackExpense.trackExpense).toHaveBeenCalledWith(
expect.objectContaining({
hasCompletedGuidedSetupFlow: true,
}),
);
});
});

describe('getMoneyRequestParticipantOptions', () => {
Expand Down
Loading