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
2 changes: 2 additions & 0 deletions src/libs/API/parameters/TrackExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type TrackExpenseParams = {
distance?: number;
gpsCoordinates?: string;
isDistance?: boolean;
odometerStart?: number;
odometerEnd?: number;
};

export default TrackExpenseParams;
40 changes: 38 additions & 2 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@
};

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

Check warning on line 814 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 @@ -907,7 +907,7 @@
};

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

Check warning on line 910 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 @@ -921,7 +921,7 @@
});

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

Check warning on line 924 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 @@ -930,7 +930,7 @@
});

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

Check warning on line 933 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 @@ -944,7 +944,7 @@
});

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

Check warning on line 947 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 @@ -957,7 +957,7 @@
});

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

Check warning on line 960 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 @@ -966,7 +966,7 @@
});

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

Check warning on line 969 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 @@ -976,7 +976,7 @@

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

Check warning on line 979 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 @@ -985,7 +985,7 @@
});

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

Check warning on line 988 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 @@ -993,7 +993,7 @@
});

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

Check warning on line 996 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 @@ -1903,6 +1903,7 @@
transactionID: testDriveIOUParams.transaction.transactionID,
reportActionID: testDriveIOUParams.iouOptimisticParams.action.reportActionID,
});
// eslint-disable-next-line @typescript-eslint/no-deprecated
const text = Localize.translateLocal('testDrive.employeeInviteMessage', personalDetailsList?.[userAccountID]?.firstName ?? '');
const textComment = buildOptimisticAddCommentReportAction(text, undefined, userAccountID, undefined, undefined, testDriveIOUParams.testDriveCommentReportActionID);
textComment.reportAction.created = DateUtils.subtractMillisecondsFromDateTime(testDriveIOUParams.iouOptimisticParams.createdAction.created, 1);
Expand Down Expand Up @@ -2592,6 +2593,7 @@
key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iou.report.reportID}`,
onyxMethod: Onyx.METHOD.SET,
// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
value: buildNextStepNew({
report: iou.report,
predictedNextStatus: iou.report.statusNum ?? CONST.REPORT.STATE_NUM.OPEN,
Expand Down Expand Up @@ -3551,6 +3553,7 @@
const optimisticPolicyRecentlyUsedCategories = mergePolicyRecentlyUsedCategories(category, policyRecentlyUsedCategories);
const optimisticPolicyRecentlyUsedTags = buildOptimisticPolicyRecentlyUsedTags({
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook
// eslint-disable-next-line @typescript-eslint/no-deprecated
policyTags: getPolicyTagsData(iouReport.policyID),
policyRecentlyUsedTags,
transactionTags: tag,
Expand Down Expand Up @@ -3646,6 +3649,7 @@
iouReport.statusNum ?? (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.OPEN);
const hasViolations = hasViolationsReportUtils(iouReport.reportID, transactionViolations, currentUserAccountIDParam, currentUserEmailParam);
// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
const optimisticNextStepDeprecated = buildNextStepNew({
report: iouReport,
predictedNextStatus,
Expand Down Expand Up @@ -3923,6 +3927,7 @@
const optimisticPolicyRecentlyUsedCategories = mergePolicyRecentlyUsedCategories(category, policyRecentlyUsedCategories);
const optimisticPolicyRecentlyUsedTags = buildOptimisticPolicyRecentlyUsedTags({
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook
// eslint-disable-next-line @typescript-eslint/no-deprecated
policyTags: getPolicyTagsData(iouReport.policyID),
policyRecentlyUsedTags,
transactionTags: tag,
Expand Down Expand Up @@ -3980,6 +3985,7 @@
const predictedNextStatus =
iouReport.statusNum ?? (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.OPEN);
// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
const optimisticNextStepDeprecated = buildNextStepNew({
report: iouReport,
predictedNextStatus,
Expand Down Expand Up @@ -4810,6 +4816,7 @@
if (hasModifiedTag) {
const optimisticPolicyRecentlyUsedTags = buildOptimisticPolicyRecentlyUsedTags({
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook
// eslint-disable-next-line @typescript-eslint/no-deprecated
policyTags: getPolicyTagsData(iouReport?.policyID),
policyRecentlyUsedTags,
transactionTags: transactionChanges.tag,
Expand Down Expand Up @@ -4990,6 +4997,7 @@
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReport?.reportID}`,
// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
value: buildNextStepNew({
report: moneyRequestReport,
predictedNextStatus: iouReport?.statusNum ?? CONST.REPORT.STATUS_NUM.OPEN,
Expand Down Expand Up @@ -6818,6 +6826,7 @@
}

if (shouldHandleNavigation) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => removeDraftTransactionsByIDs(draftTransactionIDs));

const trackReport = Navigation.getReportRouteByID(linkedTrackedExpenseReportAction?.childReportID);
Expand Down Expand Up @@ -6954,6 +6963,7 @@
playSound(SOUNDS.DONE);
API.write(WRITE_COMMANDS.CREATE_PER_DIEM_REQUEST, parameters, onyxData);

// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
handleNavigateAfterExpenseCreate({activeReportID, transactionID: transaction.transactionID, isFromGlobalCreate, shouldHandleNavigation});

Expand Down Expand Up @@ -7353,6 +7363,7 @@
playSound(SOUNDS.DONE);
API.write(WRITE_COMMANDS.CREATE_PER_DIEM_REQUEST, parameters, onyxData);

// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
dismissModalAndOpenReportInInboxTab(chatReport.reportID);

Expand Down Expand Up @@ -7694,7 +7705,13 @@
customUnitRateID,
description: parsedComment,
gpsCoordinates,
isDistance: isGPSDistanceRequest || isMapDistanceRequest(transaction) || isManualDistanceRequestTransactionUtils(transaction),
isDistance:
isGPSDistanceRequest ||
isMapDistanceRequest(transaction) ||
isManualDistanceRequestTransactionUtils(transaction) ||
isOdometerDistanceRequestTransactionUtils(transaction),
odometerStart,
odometerEnd,
};
if (actionableWhisperReportActionIDParam) {
parameters.actionableWhisperReportActionID = actionableWhisperReportActionIDParam;
Expand All @@ -7705,6 +7722,7 @@
}

if (shouldHandleNavigation) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => removeDraftTransactions());
}

Expand Down Expand Up @@ -7820,6 +7838,7 @@
reportID: CONST.REPORT.SPLIT_REPORT_ID,
comment,
created,
// eslint-disable-next-line @typescript-eslint/no-deprecated
merchant: merchant || Localize.translateLocal('iou.expense'),
receipt,
category,
Expand Down Expand Up @@ -8124,6 +8143,7 @@
reportID: oneOnOneIOUReport.reportID,
comment,
created,
// eslint-disable-next-line @typescript-eslint/no-deprecated
merchant: merchant || Localize.translateLocal('iou.expense'),
category,
tag,
Expand Down Expand Up @@ -8190,6 +8210,7 @@
const optimisticPolicyRecentlyUsedTags = isPolicyExpenseChat
? buildOptimisticPolicyRecentlyUsedTags({
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook
// eslint-disable-next-line @typescript-eslint/no-deprecated
policyTags: getPolicyTagsData(participant.policyID),
policyRecentlyUsedTags,
transactionTags: tag,
Expand Down Expand Up @@ -8541,6 +8562,7 @@
playSound(SOUNDS.DONE);

API.write(WRITE_COMMANDS.CREATE_DISTANCE_REQUEST, parameters, onyxData);
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => removeDraftTransaction(CONST.IOU.OPTIMISTIC_TRANSACTION_ID));
const activeReportID = isMoneyRequestReport && report?.reportID ? report.reportID : parameters.chatReportID;

Expand Down Expand Up @@ -8776,6 +8798,7 @@
}

const hasNonReimbursableTransactions = hasNonReimbursableTransactionsReportUtils(iouReport?.reportID);
// eslint-disable-next-line @typescript-eslint/no-deprecated
const messageText = Localize.translateLocal(
hasNonReimbursableTransactions ? 'iou.payerSpentAmount' : 'iou.payerOwesAmount',
convertToDisplayString(updatedIOUReport?.total, updatedIOUReport?.currency),
Expand Down Expand Up @@ -9062,6 +9085,7 @@
// First, update the reportActions to ensure related actions are not displayed.
Onyx.update(reportActionsOnyxUpdates).then(() => {
Navigation.goBack(urlToNavigateBack);
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
if (shouldDeleteIOUReport) {
clearAllRelatedReportActionErrors(reportID, reportAction, originalReportID);
Expand Down Expand Up @@ -10132,6 +10156,7 @@
if (!isInvoiceReport) {
currentNextStepDeprecated = iouReportCurrentNextStepDeprecated ?? null;
// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
optimisticNextStepDeprecated = buildNextStepNew({report: iouReport, predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED});
optimisticNextStep = buildOptimisticNextStep({report: iouReport, predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED});
}
Expand Down Expand Up @@ -10529,6 +10554,7 @@
}
const iouReport = updatedIouReport?.reportID === action.childReportID ? updatedIouReport : getReportOrDraftReport(action.childReportID);
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const policy = getPolicy(iouReport?.policyID);
// Only show to the actual payer, exclude admins with bank account access
const shouldShowSettlementButton =
Expand Down Expand Up @@ -10934,6 +10960,7 @@
const predictedNextStatus = CONST.REPORT.STATUS_NUM.OPEN;

// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
const optimisticNextStepDeprecated = buildNextStepNew({
report: expenseReport,
predictedNextStatus: CONST.REPORT.STATUS_NUM.OPEN,
Expand Down Expand Up @@ -11116,6 +11143,7 @@
const predictedNextStatus = CONST.REPORT.STATUS_NUM.OPEN;

// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
const optimisticNextStepDeprecated = buildNextStepNew({
report: expenseReport,
predictedNextStatus: CONST.REPORT.STATUS_NUM.OPEN,
Expand Down Expand Up @@ -11286,6 +11314,7 @@
const optimisticUnapprovedReportAction = buildOptimisticUnapprovedReportAction(expenseReport.total ?? 0, expenseReport.currency ?? '', expenseReport.reportID);

// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
const optimisticNextStepDeprecated = buildNextStepNew({
report: expenseReport,
predictedNextStatus: CONST.REPORT.STATUS_NUM.SUBMITTED,
Expand Down Expand Up @@ -11468,7 +11497,8 @@
// buildOptimisticNextStep is used in parallel
const optimisticNextStepDeprecated = isDEWPolicy
? null
: buildNextStepNew({
: // eslint-disable-next-line @typescript-eslint/no-deprecated
buildNextStepNew({
report: expenseReport,
predictedNextStatus: isSubmitAndClosePolicy ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.SUBMITTED,
policy,
Expand Down Expand Up @@ -11728,6 +11758,7 @@
const statusNum: ValueOf<typeof CONST.REPORT.STATUS_NUM> = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED;

// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
const optimisticNextStepDeprecated = buildNextStepNew({
report: expenseReport,
predictedNextStatus: statusNum,
Expand Down Expand Up @@ -11890,6 +11921,7 @@
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`,
// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
value: buildNextStepNew({
report: expenseReport,
predictedNextStatus: CONST.REPORT.STATUS_NUM.REIMBURSED,
Expand Down Expand Up @@ -12146,6 +12178,7 @@

if (transactionPolicy && isPaidGroupPolicy(transactionPolicy) && newTransaction) {
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook
// eslint-disable-next-line @typescript-eslint/no-deprecated
const policyTagList = getPolicyTagsData(transactionPolicy.id);
const currentTransactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? [];
const violationsOnyxData = ViolationsUtils.getViolationsOnyxData(
Expand Down Expand Up @@ -12272,6 +12305,7 @@

if (transactionPolicy && isPaidGroupPolicy(transactionPolicy) && newTransaction) {
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook
// eslint-disable-next-line @typescript-eslint/no-deprecated
const policyTagList = getPolicyTagsData(transactionPolicy.id);
const currentTransactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? [];
const violationsOnyxData = ViolationsUtils.getViolationsOnyxData(
Expand Down Expand Up @@ -13573,6 +13607,7 @@
const takeControlReportAction = buildOptimisticChangeApproverReportAction(accountID, accountID);

// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
const optimisticNextStepDeprecated = buildNextStepNew({
report: {...report, managerID: accountID},
predictedNextStatus: report.statusNum ?? CONST.REPORT.STATUS_NUM.SUBMITTED,
Expand Down Expand Up @@ -13688,6 +13723,7 @@
const takeControlReportAction = buildOptimisticChangeApproverReportAction(newApproverAccountID, accountID);

// buildOptimisticNextStep is used in parallel
// eslint-disable-next-line @typescript-eslint/no-deprecated
const optimisticNextStepDeprecated = buildNextStepNew({
report: {...report, managerID: newApproverAccountID},
predictedNextStatus: report.statusNum ?? CONST.REPORT.STATUS_NUM.SUBMITTED,
Expand Down
Loading