From f86458d5b98aa5e10832d15f3176b5dc286a03c2 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 12:58:18 +0200 Subject: [PATCH 01/18] skip track manual --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + .../FloatingActionButtonAndPopover.tsx | 6 +++--- .../iou/request/step/IOURequestStepAmount.tsx | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 15 +++++++++++++-- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index ed2587e5e2c6..dc34a7d2947c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -650,6 +650,7 @@ export default { nextStep: 'Next Steps', finished: 'Finished', submitAmount: ({amount}: RequestAmountParams) => `submit ${amount}`, + trackAmount: ({amount}: RequestAmountParams) => `track ${amount}`, submittedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `submitted ${formattedAmount}${comment ? ` for ${comment}` : ''}`, trackedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `tracking ${formattedAmount}${comment ? ` for ${comment}` : ''}`, splitAmount: ({amount}: SplitAmountParams) => `split ${amount}`, diff --git a/src/languages/es.ts b/src/languages/es.ts index beb654cf0bc4..e72a67cba3d9 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -643,6 +643,7 @@ export default { nextStep: 'Pasos Siguientes', finished: 'Finalizado', submitAmount: ({amount}: RequestAmountParams) => `solicitar ${amount}`, + trackAmount: ({amount}: RequestAmountParams) => `seguimiento de ${amount}`, submittedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `solicitó ${formattedAmount}${comment ? ` para ${comment}` : ''}`, trackedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `realizó un seguimiento de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, splitAmount: ({amount}: SplitAmountParams) => `dividir ${amount}`, diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 60fed8e7af2e..b1ed2bf8bf6e 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -193,13 +193,13 @@ function FloatingActionButtonAndPopover( Task.clearOutTaskInfoAndNavigate(quickAction?.chatReportID ?? '', quickActionReport, quickAction.targetAccountID ?? 0, true); break; case CONST.QUICK_ACTIONS.TRACK_MANUAL: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.MANUAL, true); break; case CONST.QUICK_ACTIONS.TRACK_SCAN: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.SCAN); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.SCAN, true); break; case CONST.QUICK_ACTIONS.TRACK_DISTANCE: - IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE); + IOU.startMoneyRequest(CONST.IOU.TYPE.TRACK_EXPENSE, quickAction?.chatReportID ?? '', CONST.IOU.REQUEST_TYPE.DISTANCE, true); break; default: } diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 2cc59bf0af14..4c8e315f2863 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -85,7 +85,7 @@ function IOURequestStepAmount({ // For quick button actions, we'll skip the confirmation page unless the report is archived or this is a workspace request, as // the user will have to add a merchant. const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (!skipConfirmation || !report?.reportID) { return false; } diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index a5ed35374e00..1c67def39a3c 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -318,10 +318,21 @@ function MoneyRequestAmountForm( if (skipConfirmation) { if (currentAmount !== '') { const currencyAmount = CurrencyUtils.convertToDisplayString(CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)), currency) ?? ''; - const text = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitAmount', {amount: currencyAmount}) : translate('iou.submitAmount', {amount: currencyAmount}); + let text = translate('iou.submitAmount', {amount: currencyAmount});; + if (iouType === CONST.IOU.TYPE.SPLIT) { + text = translate('iou.splitAmount', {amount: currencyAmount}); + } else if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + text = translate('iou.trackAmount', {amount: currencyAmount}); + } return text[0].toUpperCase() + text.slice(1); } - return iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.splitExpense') : translate('iou.submitExpense'); + + if (iouType === CONST.IOU.TYPE.SPLIT) { + return translate('iou.splitExpense'); + } else if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + return translate('iou.trackExpense'); + } + return translate('iou.submitExpense'); } return isEditing ? translate('common.save') : translate('common.next'); }, [skipConfirmation, iouType, currentAmount, currency, isEditing, translate]); From cc21ae055997160684ac1b972261e49623058014 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 13:05:12 +0200 Subject: [PATCH 02/18] Add button correctly for distance --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/pages/iou/request/step/IOURequestStepDistance.tsx | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index dc34a7d2947c..bd87a36f7cc2 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -620,6 +620,7 @@ export default { participants: 'Participants', submitExpense: 'Submit expense', trackExpense: 'Track expense', + trackDistance: 'Track distance', pay: 'Pay', cancelPayment: 'Cancel payment', cancelPaymentConfirmation: 'Are you sure that you want to cancel this payment?', diff --git a/src/languages/es.ts b/src/languages/es.ts index e72a67cba3d9..443a5eae4e39 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -613,6 +613,7 @@ export default { submitExpense: 'Presentar gasto', paySomeone: ({name}: PaySomeoneParams) => `Pagar a ${name ?? 'alguien'}`, trackExpense: 'Seguimiento de gastos', + trackDistance: 'Seguimiento de distance', pay: 'Pagar', cancelPayment: 'Cancelar el pago', cancelPaymentConfirmation: '¿Estás seguro de que quieres cancelar este pago?', diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 0602c2184365..6164e0445f24 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -113,7 +113,13 @@ function IOURequestStepDistance({ }, [report, skipConfirmation, policy, iouType]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { - buttonText = iouType === CONST.IOU.TYPE.SPLIT ? translate('iou.split') : translate('iou.submitExpense'); + if (iouType === CONST.IOU.TYPE.SPLIT) { + buttonText = translate('iou.split'); + } else if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + buttonText = translate('iou.trackDistance'); + } else { + buttonText = translate('iou.submitExpense'); + } } useEffect(() => { From e542807136ea25c8ffa3427aaa410544389472ff Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 13:15:46 +0200 Subject: [PATCH 03/18] use standard flow button text --- src/languages/en.ts | 1 - src/languages/es.ts | 1 - src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index bd87a36f7cc2..dc34a7d2947c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -620,7 +620,6 @@ export default { participants: 'Participants', submitExpense: 'Submit expense', trackExpense: 'Track expense', - trackDistance: 'Track distance', pay: 'Pay', cancelPayment: 'Cancel payment', cancelPaymentConfirmation: 'Are you sure that you want to cancel this payment?', diff --git a/src/languages/es.ts b/src/languages/es.ts index 443a5eae4e39..e72a67cba3d9 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -613,7 +613,6 @@ export default { submitExpense: 'Presentar gasto', paySomeone: ({name}: PaySomeoneParams) => `Pagar a ${name ?? 'alguien'}`, trackExpense: 'Seguimiento de gastos', - trackDistance: 'Seguimiento de distance', pay: 'Pagar', cancelPayment: 'Cancelar el pago', cancelPaymentConfirmation: '¿Estás seguro de que quieres cancelar este pago?', diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 6164e0445f24..7421122d0ce1 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -116,7 +116,7 @@ function IOURequestStepDistance({ if (iouType === CONST.IOU.TYPE.SPLIT) { buttonText = translate('iou.split'); } else if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { - buttonText = translate('iou.trackDistance'); + buttonText = translate('iou.trackExpense'); } else { buttonText = translate('iou.submitExpense'); } From c370614fc437ed2c2afee293bdeb0e52384b3150 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 13:17:20 +0200 Subject: [PATCH 04/18] skip confirmation in all --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 7421122d0ce1..31c1003f23ad 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -105,7 +105,7 @@ function IOURequestStepDistance({ // 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 const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (!skipConfirmation || !report?.reportID) { return false; } diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 84c2137dafda..ac259b6f12a9 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -65,7 +65,7 @@ function IOURequestStepScan({ // 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 const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (!skipConfirmation || !report?.reportID) { return false; } diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 8bca59b11580..0248f0faafa0 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -80,7 +80,7 @@ function IOURequestStepScan({ // 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 const shouldSkipConfirmation: boolean = useMemo(() => { - if (!skipConfirmation || !report?.reportID || iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (!skipConfirmation || !report?.reportID) { return false; } From 95493bc6bc634ea301c4f23847d5399f0f01f368 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 14:21:46 +0200 Subject: [PATCH 05/18] wrap up mnual --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 4c8e315f2863..8dfac6dff134 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -197,6 +197,19 @@ function IOURequestStepAmount({ ); return; } + if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + IOU.trackExpense( + report, + backendAmount, + currency ?? 'USD', + transaction?.created ?? '', + '', + currentUserPersonalDetails.login ?? '', + currentUserPersonalDetails.accountID ?? 0, + participants[0], + '', + ); + } } IOU.setMoneyRequestParticipantsFromReport(transactionID, report); Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID)); From 6e920bc31552d07dc4c1f0e92aff6cecafce0e2e Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 14:29:54 +0200 Subject: [PATCH 06/18] handle receipts --- .../iou/request/step/IOURequestStepAmount.tsx | 1 + .../step/IOURequestStepScan/index.native.tsx | 19 +++++++++++++++++-- .../request/step/IOURequestStepScan/index.tsx | 19 +++++++++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 8dfac6dff134..3fe152091e63 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -209,6 +209,7 @@ function IOURequestStepAmount({ participants[0], '', ); + return; } } IOU.setMoneyRequestParticipantsFromReport(transactionID, report); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index ac259b6f12a9..f9730324d37b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -219,14 +219,29 @@ function IOURequestStepScan({ }); return; } + if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + IOU.trackExpense( + report, + 0, + transaction?.currency ?? 'USD', + transaction?.created ?? '', + '', + currentUserPersonalDetails.login ?? '', + currentUserPersonalDetails.accountID ?? 0, + participants[0], + '', + receipt, + ); + return; + } IOU.requestMoney( report, 0, transaction?.currency ?? 'USD', transaction?.created ?? '', '', - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, + currentUserPersonalDetails.login ?? '', + currentUserPersonalDetails.accountID ?? 0, participants[0], '', receipt, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 0248f0faafa0..82b4ce0f0027 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -259,14 +259,29 @@ function IOURequestStepScan({ }); return; } + if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + IOU.trackExpense( + report, + 0, + transaction?.currency ?? 'USD', + transaction?.created ?? '', + '', + currentUserPersonalDetails.login ?? '', + currentUserPersonalDetails.accountID ?? 0, + participants[0], + '', + receipt, + ); + return; + } IOU.requestMoney( report, 0, transaction?.currency ?? 'USD', transaction?.created ?? '', '', - currentUserPersonalDetails.login, - currentUserPersonalDetails.accountID, + currentUserPersonalDetails.login ?? '', + currentUserPersonalDetails.accountID ?? 0, participants[0], '', receipt, From 02e2ac3f52a1aae02196e7b37ce10cd1424abca0 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 16:43:11 +0200 Subject: [PATCH 07/18] handle distance --- .../request/step/IOURequestStepDistance.tsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 31c1003f23ad..609783614fa6 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -223,6 +223,31 @@ function IOURequestStepDistance({ } IOU.setMoneyRequestPendingFields(transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}); IOU.setMoneyRequestMerchant(transactionID, translate('iou.routePending'), false); + if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + IOU.trackExpense( + report, + 0, + transaction?.currency ?? 'USD', + transaction?.created ?? '', + translate('iou.routePending'), + currentUserPersonalDetails.login ?? '', + currentUserPersonalDetails.accountID ?? 0, + participants[0], + '', + {}, + '', + '', + '', + 0, + false, + policy, + undefined, + undefined, + undefined, + TransactionUtils.getValidWaypoints(waypoints, true), + ); + return; + } IOU.createDistanceRequest( report, participants[0], From a3f37f97e7fc5d091eb4c066d567e5c64006b849 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 17:05:12 +0200 Subject: [PATCH 08/18] set optimistically for track too --- src/libs/actions/IOU.ts | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 7fed15335e2a..1aa73b62bf88 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -863,19 +863,34 @@ function buildOnyxDataForTrackExpense( const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); const optimisticData: OnyxUpdate[] = []; const existingTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingTransactionThreadReportID}`] ?? null; + let newQuickAction: ValueOf = isScanRequest ? CONST.QUICK_ACTIONS.TRACK_SCAN : CONST.QUICK_ACTIONS.TRACK_MANUAL; + if (TransactionUtils.isDistanceRequest(transaction)) { + newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE; + } if (chatReport) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, - value: { - ...chatReport, - lastMessageText: iouAction.message?.[0]?.text, - lastMessageHtml: iouAction.message?.[0]?.html, - lastReadTime: DateUtils.getDBTime(), - iouReportID: iouReport?.reportID, + optimisticData.push( + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, + value: { + ...chatReport, + lastMessageText: iouAction.message?.[0]?.text, + lastMessageHtml: iouAction.message?.[0]?.html, + lastReadTime: DateUtils.getDBTime(), + iouReportID: iouReport?.reportID, + }, }, - }); + { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value: { + action: newQuickAction, + chatReportID: chatReport.reportID, + isFirstQuickAction: isEmptyObject(quickAction), + }, + }, + ) } if (iouReport) { From 6b24ef0e82bc4d39d1c1e23ecfcea18b6c78937c Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 17:07:15 +0200 Subject: [PATCH 09/18] report exists --- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index f9730324d37b..87ef01b5a21b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -219,7 +219,7 @@ function IOURequestStepScan({ }); return; } - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE && report) { IOU.trackExpense( report, 0, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 82b4ce0f0027..2f3e237a2305 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -259,7 +259,7 @@ function IOURequestStepScan({ }); return; } - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE && report) { IOU.trackExpense( report, 0, From bb048a57b55e307e65765cb9768371072d949d5e Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 19 Apr 2024 17:16:28 +0200 Subject: [PATCH 10/18] lint --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- src/pages/iou/request/step/IOURequestStepDistance.tsx | 4 ++-- .../iou/request/step/IOURequestStepScan/index.native.tsx | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 3fe152091e63..8c7ee7a479ee 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -90,7 +90,7 @@ function IOURequestStepAmount({ } return !(ReportUtils.isArchivedRoom(report) || ReportUtils.isPolicyExpenseChat(report)); - }, [report, skipConfirmation, iouType]); + }, [report, skipConfirmation]); useFocusEffect( useCallback(() => { diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 609783614fa6..1c433b4287fb 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -110,7 +110,7 @@ function IOURequestStepDistance({ } return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy, iouType]); + }, [report, skipConfirmation, policy]); let buttonText = !isCreatingNewRequest ? translate('common.save') : translate('common.next'); if (shouldSkipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { @@ -271,7 +271,7 @@ function IOURequestStepDistance({ // If there was no reportID, then that means the user started this flow from the global menu // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense. Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.getRoute(iouType, transactionID, reportID)); - }, [report, iouType, reportID, transactionID, backTo, waypoints, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction, translate]); + }, [report, iouType, reportID, transactionID, backTo, waypoints, currentUserPersonalDetails, personalDetails, shouldSkipConfirmation, transaction, translate, policy]); const getError = () => { // Get route error if available else show the invalid number of waypoints error. diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 87ef01b5a21b..70a9e65b594a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -70,7 +70,7 @@ function IOURequestStepScan({ } return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy, iouType]); + }, [report, skipConfirmation, policy]); const {translate} = useLocalize(); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 2f3e237a2305..1374ba4b8e35 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -85,7 +85,7 @@ function IOURequestStepScan({ } return !ReportUtils.isArchivedRoom(report) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))); - }, [report, skipConfirmation, policy, iouType]); + }, [report, skipConfirmation, policy]); /** * On phones that have ultra-wide lens, react-webcam uses ultra-wide by default. diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 1c67def39a3c..810d178157db 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -329,7 +329,8 @@ function MoneyRequestAmountForm( if (iouType === CONST.IOU.TYPE.SPLIT) { return translate('iou.splitExpense'); - } else if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + } + if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { return translate('iou.trackExpense'); } return translate('iou.submitExpense'); From bd943d7213e6818c02eab2bec573b84ef3befec5 Mon Sep 17 00:00:00 2001 From: Alberto Date: Sat, 20 Apr 2024 02:26:52 +0200 Subject: [PATCH 11/18] prettier --- src/libs/actions/IOU.ts | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 1aa73b62bf88..eda5d3b3fb16 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -890,7 +890,7 @@ function buildOnyxDataForTrackExpense( isFirstQuickAction: isEmptyObject(quickAction), }, }, - ) + ); } if (iouReport) { diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 810d178157db..88779a96fc55 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -318,7 +318,7 @@ function MoneyRequestAmountForm( if (skipConfirmation) { if (currentAmount !== '') { const currencyAmount = CurrencyUtils.convertToDisplayString(CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount)), currency) ?? ''; - let text = translate('iou.submitAmount', {amount: currencyAmount});; + let text = translate('iou.submitAmount', {amount: currencyAmount}); if (iouType === CONST.IOU.TYPE.SPLIT) { text = translate('iou.splitAmount', {amount: currencyAmount}); } else if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { From a9b70b21530de15822153d00a41d281faed8e3bb Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 23 Apr 2024 13:25:45 +0200 Subject: [PATCH 12/18] updte constant name --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- src/pages/iou/request/step/IOURequestStepDistance.tsx | 4 ++-- .../iou/request/step/IOURequestStepScan/index.native.tsx | 2 +- src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 +- src/pages/iou/steps/MoneyRequestAmountForm.tsx | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index ee3228e06015..ef11f0cd5074 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -223,7 +223,7 @@ function IOURequestStepAmount({ ); return; } - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (iouType === CONST.IOU.TYPE.TRACK) { IOU.trackExpense( report, backendAmount, diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index afb20e689413..9133b2293d84 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -115,7 +115,7 @@ function IOURequestStepDistance({ if (shouldSkipConfirmation) { if (iouType === CONST.IOU.TYPE.SPLIT) { buttonText = translate('iou.split'); - } else if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + } else if (iouType === CONST.IOU.TYPE.TRACK) { buttonText = translate('iou.trackExpense'); } else { buttonText = translate('iou.submitExpense'); @@ -249,7 +249,7 @@ function IOURequestStepDistance({ } IOU.setMoneyRequestPendingFields(transactionID, {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}); IOU.setMoneyRequestMerchant(transactionID, translate('iou.routePending'), false); - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (iouType === CONST.IOU.TYPE.TRACK) { IOU.trackExpense( report, 0, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index da8c90b4de5c..c78972a3cdd8 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -245,7 +245,7 @@ function IOURequestStepScan({ }); return; } - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE && report) { + if (iouType === CONST.IOU.TYPE.TRACK && report) { IOU.trackExpense( report, 0, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index e541e62a1e7c..7d2e81c3985d 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -285,7 +285,7 @@ function IOURequestStepScan({ }); return; } - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE && report) { + if (iouType === CONST.IOU.TYPE.TRACK && report) { IOU.trackExpense( report, 0, diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/steps/MoneyRequestAmountForm.tsx index 94d5c25985e0..adcca071ca96 100644 --- a/src/pages/iou/steps/MoneyRequestAmountForm.tsx +++ b/src/pages/iou/steps/MoneyRequestAmountForm.tsx @@ -321,7 +321,7 @@ function MoneyRequestAmountForm( let text = translate('iou.submitAmount', {amount: currencyAmount}); if (iouType === CONST.IOU.TYPE.SPLIT) { text = translate('iou.splitAmount', {amount: currencyAmount}); - } else if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + } else if (iouType === CONST.IOU.TYPE.TRACK) { text = translate('iou.trackAmount', {amount: currencyAmount}); } return text[0].toUpperCase() + text.slice(1); @@ -330,7 +330,7 @@ function MoneyRequestAmountForm( if (iouType === CONST.IOU.TYPE.SPLIT) { return translate('iou.splitExpense'); } - if (iouType === CONST.IOU.TYPE.TRACK_EXPENSE) { + if (iouType === CONST.IOU.TYPE.TRACK) { return translate('iou.trackExpense'); } return translate('iou.submitExpense'); From b4747d5815ee1d55bcaf88d17c83544b742ff54c Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 23 Apr 2024 13:29:34 +0200 Subject: [PATCH 13/18] left a line --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 9133b2293d84..23779cb7898c 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -311,7 +311,6 @@ function IOURequestStepDistance({ navigateToParticipantPage, navigateToConfirmationPage, ]); ->>>>>>> main const getError = () => { // Get route error if available else show the invalid number of waypoints error. From 505bfa87f2c4bfd744f459b1439dde7b6fea8397 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 23 Apr 2024 13:39:44 +0200 Subject: [PATCH 14/18] more conflict fixes --- src/libs/actions/IOU.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index fdfb4d87173e..8a46dab5d0d2 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -835,20 +835,7 @@ function buildOnyxDataForTrackExpense( } else if (isDistanceRequest) { newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE; } - optimisticData.push({ - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, - value: { - action: newQuickAction, - chatReportID: chatReport?.reportID, - isFirstQuickAction: isEmptyObject(quickAction), - }, - }); const existingTransactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingTransactionThreadReportID}`] ?? null; - let newQuickAction: ValueOf = isScanRequest ? CONST.QUICK_ACTIONS.TRACK_SCAN : CONST.QUICK_ACTIONS.TRACK_MANUAL; - if (TransactionUtils.isDistanceRequest(transaction)) { - newQuickAction = CONST.QUICK_ACTIONS.TRACK_DISTANCE; - } if (chatReport) { optimisticData.push( From 277bfa32a63533e46eb701d323a02bb1db6ff52b Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 23 Apr 2024 14:10:11 +0200 Subject: [PATCH 15/18] add dependency --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 23779cb7898c..b171ac80e0d7 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -310,6 +310,7 @@ function IOURequestStepDistance({ translate, navigateToParticipantPage, navigateToConfirmationPage, + policy, ]); const getError = () => { From 2f8cd6b6f8780f08adcdf158f9190332e4228742 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 23 Apr 2024 14:23:10 +0200 Subject: [PATCH 16/18] remove defaults --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 12 ++++++------ .../iou/request/step/IOURequestStepDistance.tsx | 8 ++++---- .../request/step/IOURequestStepScan/index.native.tsx | 8 ++++---- .../iou/request/step/IOURequestStepScan/index.tsx | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index ef11f0cd5074..14ecc5a2efed 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -185,8 +185,8 @@ function IOURequestStepAmount({ if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport({ participants, - currentUserLogin: currentUserPersonalDetails.login ?? '', - currentUserAccountID: currentUserPersonalDetails.accountID ?? 0, + currentUserLogin: currentUserPersonalDetails.login, + currentUserAccountID: currentUserPersonalDetails.accountID, amount: backendAmount, comment: '', currency, @@ -215,8 +215,8 @@ function IOURequestStepAmount({ currency, transaction?.created ?? '', '', - currentUserPersonalDetails.login ?? '', - currentUserPersonalDetails.accountID ?? 0, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, participants[0], '', {}, @@ -230,8 +230,8 @@ function IOURequestStepAmount({ currency ?? 'USD', transaction?.created ?? '', '', - currentUserPersonalDetails.login ?? '', - currentUserPersonalDetails.accountID ?? 0, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, participants[0], '', ); diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index b171ac80e0d7..33cf22766470 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -233,8 +233,8 @@ function IOURequestStepDistance({ if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport({ participants, - currentUserLogin: currentUserPersonalDetails.login ?? '', - currentUserAccountID: currentUserPersonalDetails.accountID ?? 0, + currentUserLogin: currentUserPersonalDetails.login, + currentUserAccountID: currentUserPersonalDetails.accountID, amount: 0, comment: '', currency: transaction?.currency ?? 'USD', @@ -256,8 +256,8 @@ function IOURequestStepDistance({ transaction?.currency ?? 'USD', transaction?.created ?? '', translate('iou.routePending'), - currentUserPersonalDetails.login ?? '', - currentUserPersonalDetails.accountID ?? 0, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, participants[0], '', {}, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index c78972a3cdd8..5a95b78779e5 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -252,8 +252,8 @@ function IOURequestStepScan({ transaction?.currency ?? 'USD', transaction?.created ?? '', '', - currentUserPersonalDetails.login ?? '', - currentUserPersonalDetails.accountID ?? 0, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, participants[0], '', receipt, @@ -266,8 +266,8 @@ function IOURequestStepScan({ transaction?.currency ?? 'USD', transaction?.created ?? '', '', - currentUserPersonalDetails.login ?? '', - currentUserPersonalDetails.accountID ?? 0, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, participants[0], '', receipt, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 7d2e81c3985d..c391d87e23be 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -292,8 +292,8 @@ function IOURequestStepScan({ transaction?.currency ?? 'USD', transaction?.created ?? '', '', - currentUserPersonalDetails.login ?? '', - currentUserPersonalDetails.accountID ?? 0, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, participants[0], '', receipt, @@ -306,8 +306,8 @@ function IOURequestStepScan({ transaction?.currency ?? 'USD', transaction?.created ?? '', '', - currentUserPersonalDetails.login ?? '', - currentUserPersonalDetails.accountID ?? 0, + currentUserPersonalDetails.login, + currentUserPersonalDetails.accountID, participants[0], '', receipt, From a436acc4a5cdd5125ca31bb5875d90547464e17e Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 23 Apr 2024 14:32:06 +0200 Subject: [PATCH 17/18] readd some --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 14ecc5a2efed..79b7b13e4fde 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -185,7 +185,7 @@ function IOURequestStepAmount({ if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport({ participants, - currentUserLogin: currentUserPersonalDetails.login, + currentUserLogin: currentUserPersonalDetails.login ?? '', currentUserAccountID: currentUserPersonalDetails.accountID, amount: backendAmount, comment: '', diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 33cf22766470..5c9dea50b403 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -233,7 +233,7 @@ function IOURequestStepDistance({ if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.splitBillAndOpenReport({ participants, - currentUserLogin: currentUserPersonalDetails.login, + currentUserLogin: currentUserPersonalDetails.login ?? '', currentUserAccountID: currentUserPersonalDetails.accountID, amount: 0, comment: '', From 19ab5624a87a53b182b538a3de92fa66ad475cca Mon Sep 17 00:00:00 2001 From: Alberto Date: Wed, 24 Apr 2024 00:23:17 +0200 Subject: [PATCH 18/18] change label name --- src/pages/iou/request/step/IOURequestStepDistance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 6bc86cd8baba..264b4b80d985 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -255,7 +255,7 @@ function IOURequestStepDistance({ 0, transaction?.currency ?? 'USD', transaction?.created ?? '', - translate('iou.routePending'), + translate('iou.fieldPending'), currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, participants[0],