From c4f7afb64783f9a9c22d3e67fda7d12d4c5374df Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Thu, 22 Aug 2024 07:22:24 -0700 Subject: [PATCH 1/3] WIP pass customUnitRateID for track distance --- src/libs/actions/IOU.ts | 1 + .../request/step/IOURequestStepConfirmation.tsx | 15 ++++++++++++++- .../iou/request/step/IOURequestStepDistance.tsx | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index bbb6e3c48fcd..750d0b875e99 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3639,6 +3639,7 @@ function trackExpense( actionableWhisperReportActionID?: string, linkedTrackedExpenseReportAction?: OnyxTypes.ReportAction, linkedTrackedExpenseReportID?: string, + customUnitRateID = '', ) { const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentChatReport = isMoneyRequestReport ? ReportUtils.getReportOrDraftReport(report.chatReportID) : report; diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index b33ce6f56600..601117ebdfc0 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -300,9 +300,22 @@ function IOURequestStepConfirmation({ transaction.actionableWhisperReportActionID, transaction.linkedTrackedExpenseReportAction, transaction.linkedTrackedExpenseReportID, + customUnitRateID, ); }, - [report, transaction, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, transactionTaxCode, transactionTaxAmount, policy, policyTags, policyCategories, action], + [ + report, + transaction, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, + transactionTaxCode, + transactionTaxAmount, + policy, + policyTags, + policyCategories, + action, + customUnitRateID, + ], ); const createDistanceRequest = useCallback( diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 1798a95490a7..dbc2ca374e06 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -121,6 +121,7 @@ function IOURequestStepDistance({ const isCreatingNewRequest = !(backTo || isEditing); const [recentWaypoints, {status: recentWaypointsStatus}] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS); const iouRequestType = TransactionUtils.getRequestType(transaction); + const customUnitRateID = TransactionUtils.getRateID(transaction); // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace // request and the workspace requires a category or a tag @@ -303,6 +304,11 @@ function IOURequestStepDistance({ undefined, undefined, TransactionUtils.getValidWaypoints(waypoints, true), + undefined, + undefined, + undefined, + undefined, + customUnitRateID, ); return; } @@ -356,6 +362,7 @@ function IOURequestStepDistance({ policy, iouRequestType, reportNameValuePairs, + customUnitRateID, ]); const getError = () => { From b8fc6853f8ade5608985116a7419928989112a7d Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Thu, 22 Aug 2024 07:30:37 -0700 Subject: [PATCH 2/3] Pass customUnitRateID straight to API --- src/libs/API/parameters/TrackExpenseParams.ts | 1 + src/libs/actions/IOU.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libs/API/parameters/TrackExpenseParams.ts b/src/libs/API/parameters/TrackExpenseParams.ts index d5e1de2e625b..3a7d0df6736c 100644 --- a/src/libs/API/parameters/TrackExpenseParams.ts +++ b/src/libs/API/parameters/TrackExpenseParams.ts @@ -27,6 +27,7 @@ type TrackExpenseParams = { createdReportActionIDForThread: string; waypoints?: string; actionableWhisperReportActionID?: string; + customUnitRateID?: string; }; export default TrackExpenseParams; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 750d0b875e99..4fdd8c4dc214 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3779,6 +3779,7 @@ function trackExpense( transactionThreadReportID: transactionThreadReportID ?? '-1', createdReportActionIDForThread: createdReportActionIDForThread ?? '-1', waypoints: validWaypoints ? JSON.stringify(validWaypoints) : undefined, + customUnitRateID, }; if (actionableWhisperReportActionIDParam) { parameters.actionableWhisperReportActionID = actionableWhisperReportActionIDParam; From 5201a6ce47424b9485d72b9d6afb1e8b87b66e91 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Thu, 22 Aug 2024 07:35:09 -0700 Subject: [PATCH 3/3] Default to undefined to match other params --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 4fdd8c4dc214..d934b93938fb 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3639,7 +3639,7 @@ function trackExpense( actionableWhisperReportActionID?: string, linkedTrackedExpenseReportAction?: OnyxTypes.ReportAction, linkedTrackedExpenseReportID?: string, - customUnitRateID = '', + customUnitRateID?: string, ) { const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentChatReport = isMoneyRequestReport ? ReportUtils.getReportOrDraftReport(report.chatReportID) : report;