From 4d9d193f09ef42b84d728615b1853993b7474b56 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 5 Jan 2024 16:13:22 +0700 Subject: [PATCH 1/6] set default category for distance request --- src/pages/iou/request/step/IOURequestStepConfirmation.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index d41442edd670..3ff22ba218ab 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -115,6 +115,15 @@ function IOURequestStepConfirmation({ IOU.setMoneyRequestBillable_temporaryForRefactor(transactionID, defaultBillable); }, [transactionID, defaultBillable]); + const defaultCategory = _.chain(policy) + .get('customUnits') + .find((customUnit) => customUnit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE) + .get('defaultCategory') + .value(); + useEffect(() => { + IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, defaultCategory); + }, [transactionID, defaultCategory]); + const navigateBack = useCallback(() => { // If there is not a report attached to the IOU with a reportID, then the participants were manually selected and the user needs taken // back to the participants step From 62f1fb19cf7f9c62ed0245876ba6f5551961ed5d Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 5 Jan 2024 16:26:21 +0700 Subject: [PATCH 2/6] use lodashGet instead --- .../iou/request/step/IOURequestStepConfirmation.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 3ff22ba218ab..27d284eb4965 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -115,11 +115,11 @@ function IOURequestStepConfirmation({ IOU.setMoneyRequestBillable_temporaryForRefactor(transactionID, defaultBillable); }, [transactionID, defaultBillable]); - const defaultCategory = _.chain(policy) - .get('customUnits') - .find((customUnit) => customUnit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE) - .get('defaultCategory') - .value(); + const defaultCategory = lodashGet( + _.find(lodashGet(policy, 'customUnits', {}), (customUnit) => customUnit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE), + 'defaultCategory', + '', + ); useEffect(() => { IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, defaultCategory); }, [transactionID, defaultCategory]); From 556b831303bbc594b0c682f1bb993b2623fd0d27 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 19 Jan 2024 01:36:30 +0700 Subject: [PATCH 3/6] set default category only when unset --- src/pages/iou/request/step/IOURequestStepConfirmation.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index ee2a151c7876..0f535cb60e14 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -121,6 +121,9 @@ function IOURequestStepConfirmation({ '', ); useEffect(() => { + if (!_.isEmpty(transaction.category)) { + return; + } IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, defaultCategory); }, [transactionID, defaultCategory]); From c7925f5820f36f06abd46bd3461f8cac70774355 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 23 Jan 2024 02:05:19 +0700 Subject: [PATCH 4/6] fix lint --- src/pages/iou/request/step/IOURequestStepConfirmation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 0f535cb60e14..029836d0c654 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -125,7 +125,7 @@ function IOURequestStepConfirmation({ return; } IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, defaultCategory); - }, [transactionID, defaultCategory]); + }, [transactionID, transaction.category, defaultCategory]); const navigateBack = useCallback(() => { // If there is not a report attached to the IOU with a reportID, then the participants were manually selected and the user needs taken From 1296790702833467b0fd7b5f016afb6ab160957b Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 2 Feb 2024 16:56:01 +0700 Subject: [PATCH 5/6] set default category for distance request only --- src/pages/iou/request/step/IOURequestStepConfirmation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 029836d0c654..6c3d40dc33ad 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -121,7 +121,7 @@ function IOURequestStepConfirmation({ '', ); useEffect(() => { - if (!_.isEmpty(transaction.category)) { + if (requestType !== CONST.IOU.REQUEST_TYPE.DISTANCE || !_.isEmpty(transaction.category)) { return; } IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, defaultCategory); From cbbc7a37cb7903fe7028ba170b86c06d4cdf736b Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 2 Feb 2024 17:01:13 +0700 Subject: [PATCH 6/6] fix lint --- src/pages/iou/request/step/IOURequestStepConfirmation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index acd66fb1a3ed..560e87b6d802 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -125,7 +125,7 @@ function IOURequestStepConfirmation({ return; } IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, defaultCategory); - }, [transactionID, transaction.category, defaultCategory]); + }, [transactionID, transaction.category, requestType, defaultCategory]); const navigateBack = useCallback(() => { // If there is not a report attached to the IOU with a reportID, then the participants were manually selected and the user needs taken