Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/libs/actions/IOU/Duplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ function duplicateExpenseTransaction({
quickAction,
recentWaypoints,
betas,
isSelfTourViewed,
};
return trackExpense(trackExpenseParams);
}
Expand Down
4 changes: 4 additions & 0 deletions src/libs/actions/IOU/MoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ type MoneyRequestStepDistanceNavigationParams = {
recentWaypoints: OnyxEntry<RecentWaypoint[]>;
unit?: Unit;
personalOutputCurrency?: string;
isSelfTourViewed: boolean;
amountOwed: OnyxEntry<number>;
};

Expand Down Expand Up @@ -233,6 +234,7 @@ function createTransaction({
quickAction,
recentWaypoints,
betas,
isSelfTourViewed,
});
} else {
const existingTransactionID = getExistingTransactionID(transaction?.linkedTrackedExpenseReportAction);
Expand Down Expand Up @@ -589,6 +591,7 @@ function handleMoneyRequestStepDistanceNavigation({
recentWaypoints,
unit,
personalOutputCurrency,
isSelfTourViewed,
amountOwed,
}: MoneyRequestStepDistanceNavigationParams) {
const isManualDistance = manualDistance !== undefined;
Expand Down Expand Up @@ -672,6 +675,7 @@ function handleMoneyRequestStepDistanceNavigation({
quickAction,
recentWaypoints,
betas,
isSelfTourViewed,
});
return;
}
Expand Down
8 changes: 8 additions & 0 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@
quickAction: OnyxEntry<OnyxTypes.QuickAction>;
recentWaypoints: OnyxEntry<OnyxTypes.RecentWaypoint[]>;
betas: OnyxEntry<OnyxTypes.Beta[]>;
isSelfTourViewed: boolean;
};

type GetTrackExpenseInformationTransactionParams = {
Expand Down Expand Up @@ -765,10 +766,11 @@
activePolicyID: string | undefined;
quickAction: OnyxEntry<OnyxTypes.QuickAction>;
betas: OnyxEntry<OnyxTypes.Beta[]>;
isSelfTourViewed: boolean;
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 773 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -867,7 +869,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 872 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -881,7 +883,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 886 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -890,7 +892,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 895 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -904,7 +906,7 @@
});

let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {};
Onyx.connect({

Check warning on line 909 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -917,7 +919,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 922 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -926,7 +928,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 931 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -936,7 +938,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 941 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -945,7 +947,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 950 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand All @@ -953,7 +955,7 @@
});

let allReportActions: OnyxCollection<OnyxTypes.ReportActions>;
Onyx.connect({

Check warning on line 958 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -3688,6 +3690,7 @@
activePolicyID,
quickAction,
betas,
isSelfTourViewed,
} = params;
const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams;
const {policy, policyCategories, policyTagList} = policyParams;
Expand Down Expand Up @@ -3829,6 +3832,7 @@
currentUserEmailParam,
introSelected,
activePolicyID,
isSelfTourViewed,
});
createdWorkspaceParams = workspaceData.params;
onyxData.optimisticData?.push(...(workspaceData.optimisticData ?? []));
Expand Down Expand Up @@ -6482,6 +6486,7 @@
quickAction,
recentWaypoints = [],
betas,
isSelfTourViewed,
} = params;
const {participant, payeeAccountID, payeeEmail} = participantParams;
const {policy, policyCategories, policyTagList} = policyData;
Expand Down Expand Up @@ -6554,6 +6559,7 @@
customUnitRateID,
},
quickAction,
isSelfTourViewed,
};

const {
Expand Down Expand Up @@ -6617,6 +6623,7 @@
activePolicyID,
quickAction,
betas,
isSelfTourViewed,
}) ?? {};
const activeReportID = isMoneyRequestReport ? report?.reportID : chatReport?.reportID;
const onyxData: TrackedExpenseParams['onyxData'] = trackExpenseInformationOnyxData;
Expand Down Expand Up @@ -13059,6 +13066,7 @@
buildOnyxDataForMoneyRequest,
createSplitsAndOnyxData,
getDeleteTrackExpenseInformation,
getTrackExpenseInformation,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to export this function?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dukenv0307 How about this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I export to test this function

getMoneyRequestInformation,
getOrCreateOptimisticSplitChatReport,
};
Expand Down
1 change: 1 addition & 0 deletions src/pages/Share/SubmitDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function SubmitDetailsPage({
quickAction,
recentWaypoints,
betas,
isSelfTourViewed,
});
} else {
const existingTransactionID = getExistingTransactionID(transaction.linkedTrackedExpenseReportAction);
Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ function IOURequestStepAmount({
quickAction,
recentWaypoints,
betas,
isSelfTourViewed,
});
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ function IOURequestStepConfirmation({
quickAction,
recentWaypoints,
betas,
isSelfTourViewed,
});
}
},
Expand Down Expand Up @@ -923,6 +924,7 @@ function IOURequestStepConfirmation({
quickAction,
recentWaypoints,
betas,
isSelfTourViewed,
],
);

Expand Down
4 changes: 4 additions & 0 deletions src/pages/iou/request/step/IOURequestStepDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import type {IOUType} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import {hasSeenTourSelector} from '@src/selectors/Onboarding';
import type {Participant} from '@src/types/onyx/IOU';
import type {Errors} from '@src/types/onyx/OnyxCommon';
import type {Waypoint, WaypointCollection} from '@src/types/onyx/Transaction';
Expand Down Expand Up @@ -104,6 +105,7 @@ function IOURequestStepDistance({
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const isEditing = action === CONST.IOU.ACTION.EDIT;
const isEditingSplit = (iouType === CONST.IOU.TYPE.SPLIT || iouType === CONST.IOU.TYPE.SPLIT_EXPENSE) && isEditing;
Expand Down Expand Up @@ -341,6 +343,7 @@ function IOURequestStepDistance({
policyForMovingExpenses,
betas,
recentWaypoints,
isSelfTourViewed: !!isSelfTourViewed,
amountOwed,
});
}, [
Expand Down Expand Up @@ -376,6 +379,7 @@ function IOURequestStepDistance({
selfDMReport,
betas,
recentWaypoints,
isSelfTourViewed,
amountOwed,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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 type {Errors} from '@src/types/onyx/OnyxCommon';
import DistanceCounter from './DistanceCounter';
import GPSButtons from './GPSButtons';
Expand Down Expand Up @@ -57,6 +58,7 @@ function IOURequestStepDistanceGPS({
const selfDMReport = useSelfDMReport();
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const isEditing = action === CONST.IOU.ACTION.EDIT;
const isCreatingNewRequest = !isEditing;
// eslint-disable-next-line rulesdir/no-negated-variables
Expand Down Expand Up @@ -124,6 +126,7 @@ function IOURequestStepDistanceGPS({
recentWaypoints,
unit,
personalOutputCurrency: personalPolicy?.outputCurrency,
isSelfTourViewed: !!isSelfTourViewed,
amountOwed,
});
};
Expand Down
4 changes: 4 additions & 0 deletions src/pages/iou/request/step/IOURequestStepDistanceManual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 type Transaction from '@src/types/onyx/Transaction';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
import StepScreenWrapper from './StepScreenWrapper';
Expand Down Expand Up @@ -92,6 +93,7 @@ function IOURequestStepDistanceManual({
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.parentReportID)}`);
const [parentReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${getNonEmptyStringOnyxID(report?.parentReportID)}`);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});

const [splitDraftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`);

Expand Down Expand Up @@ -238,6 +240,7 @@ function IOURequestStepDistanceManual({
recentWaypoints,
unit,
personalOutputCurrency: personalPolicy?.outputCurrency,
isSelfTourViewed: !!isSelfTourViewed,
amountOwed,
});
},
Expand Down Expand Up @@ -283,6 +286,7 @@ function IOURequestStepDistanceManual({
selfDMReport,
betas,
personalPolicy?.outputCurrency,
isSelfTourViewed,
amountOwed,
],
);
Expand Down
4 changes: 4 additions & 0 deletions src/pages/iou/request/step/IOURequestStepDistanceMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import {hasSeenTourSelector} from '@src/selectors/Onboarding';
import type {Participant} from '@src/types/onyx/IOU';
import type {Errors} from '@src/types/onyx/OnyxCommon';
import type {Waypoint, WaypointCollection} from '@src/types/onyx/Transaction';
Expand Down Expand Up @@ -100,6 +101,7 @@ function IOURequestStepDistanceMap({
const [optimisticWaypoints, setOptimisticWaypoints] = useState<WaypointCollection | null>(null);
const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const isEditing = action === CONST.IOU.ACTION.EDIT;
const isEditingSplit = (iouType === CONST.IOU.TYPE.SPLIT || iouType === CONST.IOU.TYPE.SPLIT_EXPENSE) && isEditing;
const currentTransaction = isEditingSplit && !isEmpty(splitDraftTransaction) ? splitDraftTransaction : transaction;
Expand Down Expand Up @@ -333,6 +335,7 @@ function IOURequestStepDistanceMap({
policyForMovingExpenses,
betas,
recentWaypoints,
isSelfTourViewed: !!isSelfTourViewed,
amountOwed,
});
}, [
Expand Down Expand Up @@ -368,6 +371,7 @@ function IOURequestStepDistanceMap({
selfDMReport,
betas,
recentWaypoints,
isSelfTourViewed,
amountOwed,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import type {OdometerImageType} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import {hasSeenTourSelector} from '@src/selectors/Onboarding';
import type Transaction from '@src/types/onyx/Transaction';
import type {FileObject} from '@src/types/utils/Attachment';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
Expand Down Expand Up @@ -114,6 +115,7 @@ function IOURequestStepDistanceOdometer({
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
const selfDMReport = useSelfDMReport();
const {policyForMovingExpenses} = usePolicyForMovingExpenses();
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const [selectedTab, selectedTabResult] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.DISTANCE_REQUEST_TYPE}`);
const isLoadingSelectedTab = isLoadingOnyxValue(selectedTabResult);

Expand Down Expand Up @@ -469,6 +471,7 @@ function IOURequestStepDistanceOdometer({
recentWaypoints,
unit,
personalOutputCurrency: personalPolicy?.outputCurrency,
isSelfTourViewed: !!isSelfTourViewed,
amountOwed,
});
};
Expand Down
7 changes: 7 additions & 0 deletions tests/actions/IOU/MoneyRequestTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ describe('MoneyRequest', () => {
selfDMReport,
betas: [CONST.BETAS.ALL],
recentWaypoints: [] as RecentWaypoint[],
isSelfTourViewed: false,
amountOwed: 0,
};
const splitShares: SplitShares = {
Expand Down Expand Up @@ -938,6 +939,9 @@ describe('MoneyRequest', () => {
expect(IOU.trackExpense).toHaveBeenCalledWith({
report: baseParams.report,
isDraftPolicy: false,
activePolicyID: undefined,
introSelected: undefined,
Comment on lines +942 to +943

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary to pass an undefined value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they're required in trackExpense

isSelfTourViewed: false,
participantParams: {
payeeEmail: baseParams.currentUserLogin,
payeeAccountID: baseParams.currentUserAccountID,
Expand Down Expand Up @@ -965,6 +969,9 @@ describe('MoneyRequest', () => {
validWaypoints: undefined,
customUnitRateID: baseParams.customUnitRateID,
attendees: fakeTransaction?.comment?.attendees,
gpsCoordinates: undefined,
odometerStart: undefined,
odometerEnd: undefined,
},
isASAPSubmitBetaEnabled: baseParams.isASAPSubmitBetaEnabled,
currentUserAccountIDParam: baseParams.currentUserAccountID,
Expand Down
Loading
Loading