From 7fa5684c8073b3eb59ff1c522002a47ddc860ec6 Mon Sep 17 00:00:00 2001 From: mkhutornyi Date: Tue, 12 Dec 2023 02:46:31 +0100 Subject: [PATCH] fix not able to cancel selected category while creating IOU --- src/libs/actions/IOU.js | 8 ++++++++ src/pages/iou/request/step/IOURequestStepCategory.js | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index c65b56313a2d..9040d4c1607b 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -177,6 +177,13 @@ function setMoneyRequestCategory_temporaryForRefactor(transactionID, category) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {category}); } +/* + * @param {String} transactionID + */ +function resetMoneyRequestCategory_temporaryForRefactor(transactionID) { + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {category: null}); +} + /* * @param {String} transactionID * @param {String} tag @@ -3164,6 +3171,7 @@ export { startMoneyRequest, startMoneyRequest_temporaryForRefactor, resetMoneyRequestCategory, + resetMoneyRequestCategory_temporaryForRefactor, resetMoneyRequestInfo, resetMoneyRequestTag, resetMoneyRequestTag_temporaryForRefactor, diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index 34a4b693004a..7614683f1e1e 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -50,7 +50,11 @@ function IOURequestStepCategory({ * @param {String} category.searchText */ const updateCategory = (category) => { - IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, category.searchText); + if (category.searchText === transaction.category) { + IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID); + } else { + IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, category.searchText); + } navigateBack(); };