From 0d3a9f4507df0394b78fa94fc697a11e254fdd2d Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 31 Jan 2024 15:44:53 +0700 Subject: [PATCH 01/23] remove MoneyRequestCategoryPage and refactor route --- src/ROUTES.ts | 10 +++----- src/SCREENS.ts | 1 - .../MoneyRequestConfirmationList.js | 14 +++++++---- ...oraryForRefactorRequestConfirmationList.js | 10 +++++++- .../ReportActionItem/MoneyRequestView.js | 4 ++- .../AppNavigator/ModalStackNavigators.tsx | 1 - src/libs/Navigation/linkingConfig.ts | 1 - .../request/step/IOURequestStepCategory.js | 25 ++++++++++++++++--- 8 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 9c4375b84ab6..860999a6222a 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -283,10 +283,6 @@ const ROUTES = { route: ':iouType/new/description/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/description/${reportID}` as const, }, - MONEY_REQUEST_CATEGORY: { - route: ':iouType/new/category/:reportID?', - getRoute: (iouType: string, reportID = '') => `${iouType}/new/category/${reportID}` as const, - }, MONEY_REQUEST_TAG: { route: ':iouType/new/tag/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/tag/${reportID}` as const, @@ -334,9 +330,9 @@ const ROUTES = { getUrlWithBackToParam(`create/${iouType}/taxAmount/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_CATEGORY: { - route: 'create/:iouType/category/:transactionID/:reportID', - getRoute: (iouType: ValueOf, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`create/${iouType}/category/${transactionID}/${reportID}`, backTo), + route: ':action/:iouType/category/:transactionID/:reportID', + getRoute: (action: ValueOf, iouType: ValueOf, transactionID: string, reportID: string, backTo: string) => + getUrlWithBackToParam(`${action}/${iouType}/category/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_CURRENCY: { route: 'create/:iouType/currency/:transactionID/:reportID/:pageIndex?', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 2bf40caede57..0378fbc8f781 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -145,7 +145,6 @@ const SCREENS = { CURRENCY: 'Money_Request_Currency', DATE: 'Money_Request_Date', DESCRIPTION: 'Money_Request_Description', - CATEGORY: 'Money_Request_Category', TAG: 'Money_Request_Tag', MERCHANT: 'Money_Request_Merchant', WAYPOINT: 'Money_Request_Waypoint', diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index d967d04ab94b..289042aae4ee 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -742,11 +742,15 @@ function MoneyRequestConfirmationList(props) { description={translate('common.category')} numberOfLinesTitle={2} onPress={() => { - if (props.isEditingSplitBill) { - Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.CATEGORY)); - return; - } - Navigation.navigate(ROUTES.MONEY_REQUEST_CATEGORY.getRoute(props.iouType, props.reportID)); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( + CONST.IOU.ACTION.EDIT, + CONST.IOU.TYPE.SPLIT, + props.transaction.transactionID, + props.reportID, + Navigation.getActiveRouteWithoutParams(), + ), + ); }} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 2aff0444a59e..fcab2f76d65d 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -801,7 +801,15 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ description={translate('common.category')} numberOfLinesTitle={2} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams())) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( + CONST.IOU.ACTION.CREATE, + iouType, + transaction.transactionID, + reportID, + Navigation.getActiveRouteWithoutParams(), + ), + ) } style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index e03dd6e4744c..84e286812cf6 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -348,7 +348,9 @@ function MoneyRequestView({report, parentReport, parentReportActions, policyCate interactive={canEdit} shouldShowRightIcon={canEdit} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.CATEGORY))} + onPress={() => + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction.transactionID, report.reportID)) + } brickRoadIndicator={hasViolations('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} /> {canUseViolations && } diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index c9325206e5b2..fab0e5ed18cd 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -97,7 +97,6 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator require('../../../pages/iou/IOUCurrencySelection').default as React.ComponentType, [SCREENS.MONEY_REQUEST.DATE]: () => require('../../../pages/iou/MoneyRequestDatePage').default as React.ComponentType, [SCREENS.MONEY_REQUEST.DESCRIPTION]: () => require('../../../pages/iou/MoneyRequestDescriptionPage').default as React.ComponentType, - [SCREENS.MONEY_REQUEST.CATEGORY]: () => require('../../../pages/iou/MoneyRequestCategoryPage').default as React.ComponentType, [SCREENS.MONEY_REQUEST.TAG]: () => require('../../../pages/iou/MoneyRequestTagPage').default as React.ComponentType, [SCREENS.MONEY_REQUEST.MERCHANT]: () => require('../../../pages/iou/MoneyRequestMerchantPage').default as React.ComponentType, [SCREENS.IOU_SEND.ADD_BANK_ACCOUNT]: () => require('../../../pages/AddPersonalBankAccountPage').default as React.ComponentType, diff --git a/src/libs/Navigation/linkingConfig.ts b/src/libs/Navigation/linkingConfig.ts index 5df2bcf0e57b..f33a4e31f9d6 100644 --- a/src/libs/Navigation/linkingConfig.ts +++ b/src/libs/Navigation/linkingConfig.ts @@ -432,7 +432,6 @@ const linkingConfig: LinkingOptions = { [SCREENS.MONEY_REQUEST.DATE]: ROUTES.MONEY_REQUEST_DATE.route, [SCREENS.MONEY_REQUEST.CURRENCY]: ROUTES.MONEY_REQUEST_CURRENCY.route, [SCREENS.MONEY_REQUEST.DESCRIPTION]: ROUTES.MONEY_REQUEST_DESCRIPTION.route, - [SCREENS.MONEY_REQUEST.CATEGORY]: ROUTES.MONEY_REQUEST_CATEGORY.route, [SCREENS.MONEY_REQUEST.TAG]: ROUTES.MONEY_REQUEST_TAG.route, [SCREENS.MONEY_REQUEST.MERCHANT]: ROUTES.MONEY_REQUEST_MERCHANT.route, [SCREENS.MONEY_REQUEST.RECEIPT]: ROUTES.MONEY_REQUEST_RECEIPT.route, diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index 2218262e1877..21a14bfb93eb 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -8,6 +8,7 @@ import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; +import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; @@ -34,12 +35,14 @@ const defaultProps = { function IOURequestStepCategory({ report, route: { - params: {transactionID, backTo}, + params: {transactionID, backTo, action, iouType}, }, transaction, }) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const isEditing = action === CONST.IOU.ACTION.EDIT; + const isBillSplit = iouType === CONST.IOU.TYPE.SPLIT; const navigateBack = () => { Navigation.goBack(backTo || ROUTES.HOME); @@ -50,10 +53,26 @@ function IOURequestStepCategory({ * @param {String} category.searchText */ const updateCategory = (category) => { - if (category.searchText === transaction.category) { + const isSelectedCategory = category.searchText === transaction.category; + const updatedCategory = isSelectedCategory ? '' : category.searchText; + + // The case edit split bill + if (isBillSplit && isEditing) { + IOU.setDraftSplitTransaction(transaction.transactionID, {category: category.searchText}); + navigateBack(); + return; + } + // The casse edit request + if (isEditing) { + IOU.updateMoneyRequestCategory(transaction.transactionID, report.reportID, updatedCategory); + Navigation.dismissModal(); + return; + } + // The case create request monney or split bill or send money + if (isSelectedCategory) { IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID); } else { - IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, category.searchText); + IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, updatedCategory); } navigateBack(); }; From 7b3c74275ffa47a9a8b3986879a733bb7a4650e7 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 31 Jan 2024 16:13:30 +0700 Subject: [PATCH 02/23] delete old page and route type --- src/libs/Navigation/types.ts | 4 - src/pages/iou/MoneyRequestCategoryPage.js | 106 ---------------------- 2 files changed, 110 deletions(-) delete mode 100644 src/pages/iou/MoneyRequestCategoryPage.js diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 2371c764f42a..3d066ef942fd 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -207,10 +207,6 @@ type MoneyRequestNavigatorParamList = { field: string; threadReportID: string; }; - [SCREENS.MONEY_REQUEST.CATEGORY]: { - iouType: string; - reportID: string; - }; [SCREENS.MONEY_REQUEST.TAG]: { iouType: string; reportID: string; diff --git a/src/pages/iou/MoneyRequestCategoryPage.js b/src/pages/iou/MoneyRequestCategoryPage.js deleted file mode 100644 index ceb2152d2b49..000000000000 --- a/src/pages/iou/MoneyRequestCategoryPage.js +++ /dev/null @@ -1,106 +0,0 @@ -import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; -import React from 'react'; -import {withOnyx} from 'react-native-onyx'; -import CategoryPicker from '@components/CategoryPicker'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import compose from '@libs/compose'; -import Navigation from '@libs/Navigation/Navigation'; -import reportPropTypes from '@pages/reportPropTypes'; -import * as IOU from '@userActions/IOU'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import {iouDefaultProps, iouPropTypes} from './propTypes'; - -const propTypes = { - /** Navigation route context info provided by react navigation */ - route: PropTypes.shape({ - /** Route specific parameters used on this screen via route :iouType/new/category/:reportID? */ - params: PropTypes.shape({ - /** The type of IOU report, i.e. bill, request, send */ - iouType: PropTypes.string, - - /** The report ID of the IOU */ - reportID: PropTypes.string, - }), - }).isRequired, - - /* Onyx Props */ - /** The report currently being used */ - report: reportPropTypes, - - /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ - iou: iouPropTypes, -}; - -const defaultProps = { - report: {}, - iou: iouDefaultProps, -}; - -function MoneyRequestCategoryPage({route, report, iou}) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - - const reportID = lodashGet(route, 'params.reportID', ''); - const iouType = lodashGet(route, 'params.iouType', ''); - - const navigateBack = () => { - Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); - }; - - const updateCategory = (category) => { - if (category.searchText === iou.category) { - IOU.resetMoneyRequestCategory(); - } else { - IOU.setMoneyRequestCategory(category.searchText); - } - - Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); - }; - - return ( - - - {translate('iou.categorySelection')} - - - ); -} - -MoneyRequestCategoryPage.displayName = 'MoneyRequestCategoryPage'; -MoneyRequestCategoryPage.propTypes = propTypes; -MoneyRequestCategoryPage.defaultProps = defaultProps; - -export default compose( - withOnyx({ - iou: { - key: ONYXKEYS.IOU, - }, - }), - // eslint-disable-next-line rulesdir/no-multiple-onyx-in-file - withOnyx({ - report: { - key: ({route, iou}) => { - const reportID = IOU.getIOUReportID(iou, route); - - return `${ONYXKEYS.COLLECTION.REPORT}${reportID}`; - }, - }, - }), -)(MoneyRequestCategoryPage); From 27a668eb23ed9c138a4f3fa82c65c86115b6d193 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 6 Feb 2024 00:26:39 +0700 Subject: [PATCH 03/23] merge main and remove un-use functiion --- src/ROUTES.ts | 10 -------- src/libs/actions/IOU.js | 24 +------------------ .../request/step/IOURequestStepCategory.js | 11 +++------ .../step/IOURequestStepParticipants.js | 2 +- .../MoneyRequestParticipantsPage.js | 1 - 5 files changed, 5 insertions(+), 43 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 282022587b4b..63548a23317a 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -289,16 +289,6 @@ const ROUTES = { route: ':iouType/new/description/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/description/${reportID}` as const, }, -<<<<<<< HEAD - MONEY_REQUEST_TAG: { - route: ':iouType/new/tag/:reportID?', - getRoute: (iouType: string, reportID = '') => `${iouType}/new/tag/${reportID}` as const, -======= - MONEY_REQUEST_CATEGORY: { - route: ':iouType/new/category/:reportID?', - getRoute: (iouType: string, reportID = '') => `${iouType}/new/category/${reportID}` as const, ->>>>>>> main - }, MONEY_REQUEST_MERCHANT: { route: ':iouType/new/merchant/:reportID?', getRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}` as const, diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 7da6e13d1f86..fa34da0349fb 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -237,17 +237,10 @@ function setMoneyRequestMerchant_temporaryForRefactor(transactionID, merchant) { * @param {String} transactionID * @param {String} category */ -function setMoneyRequestCategory_temporaryForRefactor(transactionID, category) { +function setMoneyRequestCategory(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 @@ -3635,17 +3628,6 @@ function setMoneyRequestMerchant(merchant) { Onyx.merge(ONYXKEYS.IOU, {merchant: merchant.trim()}); } -/** - * @param {String} category - */ -function setMoneyRequestCategory(category) { - Onyx.merge(ONYXKEYS.IOU, {category}); -} - -function resetMoneyRequestCategory() { - Onyx.merge(ONYXKEYS.IOU, {category: ''}); -} - /** * @param {String} transactionID * @param {Object} taxRate @@ -3725,7 +3707,6 @@ function navigateToNextPage(iou, iouType, report, path = '') { .map((accountID) => ({accountID, selected: true})) .value(); setMoneyRequestParticipants(participants); - resetMoneyRequestCategory(); } Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, report.reportID)); return; @@ -3800,13 +3781,10 @@ export { sendMoneyWithWallet, startMoneyRequest, startMoneyRequest_temporaryForRefactor, - resetMoneyRequestCategory, - resetMoneyRequestCategory_temporaryForRefactor, resetMoneyRequestInfo, clearMoneyRequest, setMoneyRequestAmount_temporaryForRefactor, setMoneyRequestBillable_temporaryForRefactor, - setMoneyRequestCategory_temporaryForRefactor, setMoneyRequestCreated_temporaryForRefactor, setMoneyRequestCurrency_temporaryForRefactor, setMoneyRequestOriginalCurrency_temporaryForRefactor, diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index 21a14bfb93eb..6e9e4c424825 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -42,7 +42,7 @@ function IOURequestStepCategory({ const styles = useThemeStyles(); const {translate} = useLocalize(); const isEditing = action === CONST.IOU.ACTION.EDIT; - const isBillSplit = iouType === CONST.IOU.TYPE.SPLIT; + const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; const navigateBack = () => { Navigation.goBack(backTo || ROUTES.HOME); @@ -57,7 +57,7 @@ function IOURequestStepCategory({ const updatedCategory = isSelectedCategory ? '' : category.searchText; // The case edit split bill - if (isBillSplit && isEditing) { + if (isSplitBill && isEditing) { IOU.setDraftSplitTransaction(transaction.transactionID, {category: category.searchText}); navigateBack(); return; @@ -68,12 +68,7 @@ function IOURequestStepCategory({ Navigation.dismissModal(); return; } - // The case create request monney or split bill or send money - if (isSelectedCategory) { - IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID); - } else { - IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, updatedCategory); - } + IOU.setMoneyRequestCategory(transactionID, updatedCategory); navigateBack(); }; diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.js b/src/pages/iou/request/step/IOURequestStepParticipants.js index 5f1b22cab128..a6f3563bd486 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.js +++ b/src/pages/iou/request/step/IOURequestStepParticipants.js @@ -71,7 +71,7 @@ function IOURequestStepParticipants({ const goToNextStep = useCallback(() => { const nextStepIOUType = numberOfParticipants.current === 1 ? iouType : CONST.IOU.TYPE.SPLIT; IOU.setMoneyRequestTag(transactionID, ''); - IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID); + IOU.setMoneyRequestCategory(transactionID, ''); Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(nextStepIOUType, transactionID, selectedReportID.current || reportID)); }, [iouType, transactionID, reportID]); diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index ea57d88579ae..fc522816b4ce 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -87,7 +87,6 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route, transaction}) { const navigateToConfirmationStep = (moneyRequestType) => { IOU.setMoneyRequestId(moneyRequestType); - IOU.resetMoneyRequestCategory(); Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(moneyRequestType, reportID)); }; From 7104c7f0e2eb2ca04d18d0c073e483ed927fb970 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 6 Feb 2024 00:32:44 +0700 Subject: [PATCH 04/23] fix ts error --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 8ab073a372d5..7753d8d32b0a 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -323,7 +323,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction.transactionID, report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction.transactionID ?? '', report.reportID)) } brickRoadIndicator={hasViolations('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> From 388615a4cee7e2713073272772677a6ab98b56ca Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 6 Feb 2024 01:07:31 +0700 Subject: [PATCH 05/23] fix lint --- src/ROUTES.ts | 2 +- src/components/ReportActionItem/MoneyRequestView.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 63548a23317a..8c26404507f0 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -333,7 +333,7 @@ const ROUTES = { }, MONEY_REQUEST_STEP_CATEGORY: { route: ':action/:iouType/category/:transactionID/:reportID', - getRoute: (action: ValueOf, iouType: ValueOf, transactionID: string, reportID: string, backTo: string) => + getRoute: (action: ValueOf, iouType: ValueOf, transactionID: string, reportID: string, backTo: string = '') => getUrlWithBackToParam(`${action}/${iouType}/category/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_CURRENCY: { diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 7753d8d32b0a..d6ebdeed987a 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -323,7 +323,9 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction.transactionID ?? '', report.reportID)) + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID), + ) } brickRoadIndicator={hasViolations('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> From c19b5ff4aa7f22be65956c5fb895eee90997c345 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 6 Feb 2024 11:11:56 +0700 Subject: [PATCH 06/23] resolve conflict --- src/ROUTES.ts | 2 +- src/libs/actions/IOU.ts | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index ccc7082193e0..de63d4a558f4 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -329,7 +329,7 @@ const ROUTES = { }, MONEY_REQUEST_STEP_CATEGORY: { route: ':action/:iouType/category/:transactionID/:reportID', - getRoute: (action: ValueOf, iouType: ValueOf, transactionID: string, reportID: string, backTo: string = '') => + getRoute: (action: ValueOf, iouType: ValueOf, transactionID: string, reportID: string, backTo = '') => getUrlWithBackToParam(`${action}/${iouType}/category/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_CURRENCY: { diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index eccc4e5c2631..ad1987435cf1 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3562,23 +3562,11 @@ function setMoneyRequestMerchant(merchant: string) { Onyx.merge(ONYXKEYS.IOU, {merchant: merchant.trim()}); } -<<<<<<< HEAD:src/libs/actions/IOU.js /** * @param {String} transactionID * @param {Object} taxRate */ function setMoneyRequestTaxRate(transactionID, taxRate) { -======= -function setMoneyRequestCategory(category: string) { - Onyx.merge(ONYXKEYS.IOU, {category}); -} - -function resetMoneyRequestCategory() { - Onyx.merge(ONYXKEYS.IOU, {category: ''}); -} - -function setMoneyRequestTaxRate(transactionID: string, taxRate: TaxRate) { ->>>>>>> main:src/libs/actions/IOU.ts Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxRate}); } From 339c58472dacd48b9acfcf9f8f3a5ff76a204cce Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 6 Feb 2024 11:13:31 +0700 Subject: [PATCH 07/23] fix conflict --- src/libs/actions/IOU.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index ad1987435cf1..b4693a154aab 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -302,7 +302,7 @@ function setMoneyRequestMerchant_temporaryForRefactor(transactionID: string, mer * @param {String} transactionID * @param {String} category */ -function setMoneyRequestCategory(transactionID, category) { +function setMoneyRequestCategory(transactionID: string, category: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {category}); } @@ -310,7 +310,7 @@ function setMoneyRequestCategory(transactionID, category) { * @param {String} transactionID * @param {String} tag */ -function setMoneyRequestTag(transactionID, tag) { +function setMoneyRequestTag(transactionID: string, tag: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {tag}); } @@ -3566,7 +3566,7 @@ function setMoneyRequestMerchant(merchant: string) { * @param {String} transactionID * @param {Object} taxRate */ -function setMoneyRequestTaxRate(transactionID, taxRate) { +function setMoneyRequestTaxRate(transactionID: string, taxRate: TaxRate) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxRate}); } From 2c9117f8a2c3a529ff073cb732e1e3fefb3e84b4 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 6 Feb 2024 11:19:20 +0700 Subject: [PATCH 08/23] fix lint --- src/libs/actions/IOU.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b4693a154aab..583ba6ccdda9 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -59,7 +59,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; import * as Policy from './Policy'; import * as Report from './Report'; -type MoneyRequestRoute = StackScreenProps['route']; +type MoneyRequestRoute = StackScreenProps['route']; type IOURequestType = ValueOf; @@ -298,18 +298,10 @@ function setMoneyRequestMerchant_temporaryForRefactor(transactionID: string, mer Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {merchant: merchant.trim()}); } -/** - * @param {String} transactionID - * @param {String} category - */ function setMoneyRequestCategory(transactionID: string, category: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {category}); } -/* - * @param {String} transactionID - * @param {String} tag - */ function setMoneyRequestTag(transactionID: string, tag: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {tag}); } @@ -3562,10 +3554,6 @@ function setMoneyRequestMerchant(merchant: string) { Onyx.merge(ONYXKEYS.IOU, {merchant: merchant.trim()}); } -/** - * @param {String} transactionID - * @param {Object} taxRate - */ function setMoneyRequestTaxRate(transactionID: string, taxRate: TaxRate) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxRate}); } From dc0ed317c069c1928cbf015bbf3f85335415d414 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 16 Feb 2024 15:29:41 +0700 Subject: [PATCH 09/23] get default category for the edit split bill case --- ...mporaryForRefactorRequestConfirmationList.js | 8 +------- src/libs/Navigation/types.ts | 7 +++++++ src/libs/actions/IOU.ts | 17 ----------------- .../iou/request/step/IOURequestStepCategory.js | 13 ++++++++++--- .../step/withFullTransactionOrNotFound.js | 15 ++++++++++++++- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index d4c7bee99b5a..8609b1b05e4f 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -749,13 +749,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ numberOfLinesTitle={2} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( - CONST.IOU.ACTION.CREATE, - iouType, - transaction.transactionID, - reportID, - Navigation.getActiveRouteWithoutParams(), - ), + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()), ) } style={[styles.moneyRequestMenuItem]} diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 131898bfb90a..50620eea1a1b 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -255,6 +255,13 @@ type MoneyRequestNavigatorParamList = { reportID: string; backTo: string; }; + [SCREENS.MONEY_REQUEST.STEP_CATEGORY]: { + action: ValueOf; + iouType: ValueOf; + transactionID: string; + reportID: string; + backTo: string; + }; [SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: { iouType: string; transactionID: string; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 77f4402a133a..86949025ca75 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3820,23 +3820,6 @@ function setMoneyRequestCurrency(currency: string) { Onyx.merge(ONYXKEYS.IOU, {currency}); } -<<<<<<< HEAD -function setMoneyRequestDescription(comment: string) { - Onyx.merge(ONYXKEYS.IOU, {comment: comment.trim()}); -} - -function setMoneyRequestMerchant(merchant: string) { - Onyx.merge(ONYXKEYS.IOU, {merchant: merchant.trim()}); -======= -function setMoneyRequestCategory(category: string) { - Onyx.merge(ONYXKEYS.IOU, {category}); -} - -function resetMoneyRequestCategory() { - Onyx.merge(ONYXKEYS.IOU, {category: ''}); ->>>>>>> main -} - function setMoneyRequestTaxRate(transactionID: string, taxRate: TaxRate) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxRate}); } diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index 949a766820f6..d443c73dc183 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -1,4 +1,5 @@ import React from 'react'; +import _ from 'underscore'; import CategoryPicker from '@components/CategoryPicker'; import Text from '@components/Text'; import transactionPropTypes from '@components/transactionPropTypes'; @@ -9,7 +10,7 @@ import Navigation from '@libs/Navigation/Navigation'; import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; -import ROUTES from '@src/ROUTES'; +import * as ReportUtils from '@libs/ReportUtils'; import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; @@ -23,6 +24,9 @@ const propTypes = { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: transactionPropTypes, + /** The draft transaction of scan split bill */ + splitTransactionDraft: transactionPropTypes, + /** The report attached to the transaction */ report: reportPropTypes, }; @@ -30,6 +34,7 @@ const propTypes = { const defaultProps = { report: {}, transaction: {}, + splitTransactionDraft: {}, }; function IOURequestStepCategory({ @@ -38,9 +43,11 @@ function IOURequestStepCategory({ params: {transactionID, backTo, action, iouType}, }, transaction, + splitTransactionDraft, }) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const {category: transactionCategory} = ReportUtils.getTransactionDetails(_.isEmpty(splitTransactionDraft) ? transaction : splitTransactionDraft); const isEditing = action === CONST.IOU.ACTION.EDIT; const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; @@ -53,7 +60,7 @@ function IOURequestStepCategory({ * @param {String} category.searchText */ const updateCategory = (category) => { - const isSelectedCategory = category.searchText === transaction.category; + const isSelectedCategory = category.searchText === transactionCategory; const updatedCategory = isSelectedCategory ? '' : category.searchText; // The case edit split bill @@ -81,7 +88,7 @@ function IOURequestStepCategory({ > {translate('iou.categorySelection')} diff --git a/src/pages/iou/request/step/withFullTransactionOrNotFound.js b/src/pages/iou/request/step/withFullTransactionOrNotFound.js index 7cdbb3484999..1999b3a90574 100644 --- a/src/pages/iou/request/step/withFullTransactionOrNotFound.js +++ b/src/pages/iou/request/step/withFullTransactionOrNotFound.js @@ -18,12 +18,16 @@ const propTypes = { /** The report corresponding to the reportID in the route params */ transaction: transactionPropTypes, + /** The draft transaction of scan split bill */ + splitTransactionDraft: transactionPropTypes, + route: IOURequestStepRoutePropTypes.isRequired, }; const defaultProps = { forwardedRef: () => {}, transaction: {}, + splitTransactionDraft: {}, }; export default function (WrappedComponent) { @@ -31,6 +35,7 @@ export default function (WrappedComponent) { function WithFullTransactionOrNotFound({forwardedRef, ...props}) { const { transaction: {transactionID}, + splitTransactionDraft: {transactionID: splitTransactionDraftID}, } = props; const isFocused = useIsFocused(); @@ -38,7 +43,7 @@ export default function (WrappedComponent) { // If the transaction does not have a transactionID, then the transaction no longer exists in Onyx as a full transaction and the not-found page should be shown. // In addition, the not-found page should be shown only if the component screen's route is active (i.e. is focused). // This is to prevent it from showing when the modal is being dismissed while navigating to a different route (e.g. on requesting money). - if (!transactionID) { + if (!transactionID && !splitTransactionDraftID) { return ; } @@ -74,5 +79,13 @@ export default function (WrappedComponent) { return `${userAction === CONST.IOU.ACTION.CREATE ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; }, }, + splitTransactionDraft: { + key: ({route}) => { + const transactionID = lodashGet(route, 'params.transactionID', 0); + const userAction = lodashGet(route, 'params.action', CONST.IOU.ACTION.CREATE); + const isEditingSplitBill = userAction === CONST.IOU.ACTION.EDIT && lodashGet(route, 'params.iouType', CONST.IOU.TYPE.REQUEST) === CONST.IOU.TYPE.SPLIT; + return `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${isEditingSplitBill ? transactionID : '0'}`; + }, + }, })(WithFullTransactionOrNotFoundWithRef); } From aec7ec03ad0be4b0ae42e5003a1123928909b759 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 16 Feb 2024 15:34:50 +0700 Subject: [PATCH 10/23] remove edit category page --- src/pages/EditRequestCategoryPage.js | 55 ---------------------------- src/pages/EditRequestPage.js | 25 +------------ 2 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 src/pages/EditRequestCategoryPage.js diff --git a/src/pages/EditRequestCategoryPage.js b/src/pages/EditRequestCategoryPage.js deleted file mode 100644 index 205b4bf66dfa..000000000000 --- a/src/pages/EditRequestCategoryPage.js +++ /dev/null @@ -1,55 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import CategoryPicker from '@components/CategoryPicker'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@libs/Navigation/Navigation'; - -const propTypes = { - /** Transaction default category value */ - defaultCategory: PropTypes.string.isRequired, - - /** The policyID we are getting categories for */ - policyID: PropTypes.string.isRequired, - - /** Callback to fire when the Save button is pressed */ - onSubmit: PropTypes.func.isRequired, -}; - -function EditRequestCategoryPage({defaultCategory, policyID, onSubmit}) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - - const selectCategory = (category) => { - onSubmit({ - category: category.searchText, - }); - }; - - return ( - - - {translate('iou.categorySelection')} - - - ); -} - -EditRequestCategoryPage.propTypes = propTypes; -EditRequestCategoryPage.displayName = 'EditRequestCategoryPage'; - -export default EditRequestCategoryPage; diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index 29917154a527..4f086a5c825c 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -77,7 +77,7 @@ const defaultProps = { function EditRequestPage({report, route, policy, policyCategories, policyTags, parentReportActions, transaction}) { const parentReportActionID = lodashGet(report, 'parentReportActionID', '0'); const parentReportAction = lodashGet(parentReportActions, parentReportActionID, {}); - const {amount: transactionAmount, currency: transactionCurrency, category: transactionCategory, tag: transactionTag} = ReportUtils.getTransactionDetails(transaction); + const {amount: transactionAmount, currency: transactionCurrency, tag: transactionTag} = ReportUtils.getTransactionDetails(transaction); const defaultCurrency = lodashGet(route, 'params.currency', '') || transactionCurrency; const fieldToEdit = lodashGet(route, ['params', 'field'], ''); @@ -90,9 +90,6 @@ function EditRequestPage({report, route, policy, policyCategories, policyTags, p // A flag for verifying that the current report is a sub-report of a workspace chat const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); - // A flag for showing the categories page - const shouldShowCategories = isPolicyExpenseChat && (transactionCategory || OptionsListUtils.hasEnabledOptions(lodashValues(policyCategories))); - // A flag for showing the tags page const shouldShowTags = useMemo(() => isPolicyExpenseChat && (transactionTag || OptionsListUtils.hasEnabledTags(policyTagLists)), [isPolicyExpenseChat, policyTagLists, transactionTag]); @@ -145,16 +142,6 @@ function EditRequestPage({report, route, policy, policyCategories, policyTags, p [tag, transaction.transactionID, report.reportID, transactionTag, tagIndex, policy, policyTags, policyCategories], ); - const saveCategory = useCallback( - ({category: newCategory}) => { - // In case the same category has been selected, reset the category. - const updatedCategory = newCategory === transactionCategory ? '' : newCategory; - IOU.updateMoneyRequestCategory(transaction.transactionID, report.reportID, updatedCategory, policy, policyTags, policyCategories); - Navigation.dismissModal(); - }, - [transactionCategory, transaction.transactionID, report.reportID, policy, policyTags, policyCategories], - ); - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.AMOUNT) { return ( - ); - } - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.TAG && shouldShowTags) { return ( Date: Fri, 16 Feb 2024 15:40:06 +0700 Subject: [PATCH 11/23] remove all use of edit category page --- src/pages/EditRequestPage.js | 1 - src/pages/EditSplitBillPage.tsx | 20 +------------------ .../request/step/IOURequestStepCategory.js | 2 +- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index 4f086a5c825c..a64e903d96c0 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -21,7 +21,6 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import EditRequestAmountPage from './EditRequestAmountPage'; -import EditRequestCategoryPage from './EditRequestCategoryPage'; import EditRequestDistancePage from './EditRequestDistancePage'; import EditRequestReceiptPage from './EditRequestReceiptPage'; import EditRequestTagPage from './EditRequestTagPage'; diff --git a/src/pages/EditSplitBillPage.tsx b/src/pages/EditSplitBillPage.tsx index 8485fc0ed736..97a2b98a456a 100644 --- a/src/pages/EditSplitBillPage.tsx +++ b/src/pages/EditSplitBillPage.tsx @@ -16,7 +16,6 @@ import type SCREENS from '@src/SCREENS'; import type {Report, ReportActions, Transaction} from '@src/types/onyx'; import type {OriginalMessageIOU} from '@src/types/onyx/OriginalMessage'; import EditRequestAmountPage from './EditRequestAmountPage'; -import EditRequestCategoryPage from './EditRequestCategoryPage'; import EditRequestTagPage from './EditRequestTagPage'; type EditSplitBillOnyxProps = { @@ -40,12 +39,7 @@ type EditSplitBillProps = EditSplitBillOnyxProps & StackScreenProps { - setDraftSplitTransaction({category: transactionChanges.category.trim()}); - }} - /> - ); - } - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.TAG) { return ( Date: Fri, 16 Feb 2024 15:44:14 +0700 Subject: [PATCH 12/23] fix lint --- src/pages/EditRequestPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index a64e903d96c0..c155fc74e0c3 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -1,5 +1,4 @@ import lodashGet from 'lodash/get'; -import lodashValues from 'lodash/values'; import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useMemo} from 'react'; import {withOnyx} from 'react-native-onyx'; From 41e3184f0aafbab817b98a4d5822db6d4d2a3ef9 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 16 Feb 2024 16:13:28 +0700 Subject: [PATCH 13/23] only get split draft transaction on the current step --- .../request/step/IOURequestStepCategory.js | 27 ++++++++++++++----- .../step/withFullTransactionOrNotFound.js | 15 +---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index a9f40c9cdbfa..9bd00a4e23aa 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -1,5 +1,6 @@ +import lodashGet from 'lodash/get'; import React from 'react'; -import _ from 'underscore'; +import {withOnyx} from 'react-native-onyx'; import CategoryPicker from '@components/CategoryPicker'; import Text from '@components/Text'; import transactionPropTypes from '@components/transactionPropTypes'; @@ -11,6 +12,7 @@ import * as ReportUtils from '@libs/ReportUtils'; import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; @@ -24,8 +26,8 @@ const propTypes = { /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: transactionPropTypes, - /** The draft transaction of scan split bill */ - splitTransactionDraft: transactionPropTypes, + /** The draft transaction that holds data to be persisted on the current transaction */ + splitDraftTransaction: transactionPropTypes, /** The report attached to the transaction */ report: reportPropTypes, @@ -34,7 +36,7 @@ const propTypes = { const defaultProps = { report: {}, transaction: {}, - splitTransactionDraft: {}, + splitDraftTransaction: {}, }; function IOURequestStepCategory({ @@ -43,13 +45,13 @@ function IOURequestStepCategory({ params: {transactionID, backTo, action, iouType}, }, transaction, - splitTransactionDraft, + splitDraftTransaction, }) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const {category: transactionCategory} = ReportUtils.getTransactionDetails(_.isEmpty(splitTransactionDraft) ? transaction : splitTransactionDraft); const isEditing = action === CONST.IOU.ACTION.EDIT; const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; + const {category: transactionCategory} = ReportUtils.getTransactionDetails(isEditing && isSplitBill ? splitDraftTransaction : transaction); const navigateBack = () => { Navigation.goBack(backTo); @@ -100,4 +102,15 @@ IOURequestStepCategory.displayName = 'IOURequestStepCategory'; IOURequestStepCategory.propTypes = propTypes; IOURequestStepCategory.defaultProps = defaultProps; -export default compose(withWritableReportOrNotFound, withFullTransactionOrNotFound)(IOURequestStepCategory); +export default compose( + withWritableReportOrNotFound, + withFullTransactionOrNotFound, + withOnyx({ + splitDraftTransaction: { + key: ({route}) => { + const transactionID = lodashGet(route, 'params.transactionID', 0); + return `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`; + }, + }, + }), +)(IOURequestStepCategory); diff --git a/src/pages/iou/request/step/withFullTransactionOrNotFound.js b/src/pages/iou/request/step/withFullTransactionOrNotFound.js index 1999b3a90574..7cdbb3484999 100644 --- a/src/pages/iou/request/step/withFullTransactionOrNotFound.js +++ b/src/pages/iou/request/step/withFullTransactionOrNotFound.js @@ -18,16 +18,12 @@ const propTypes = { /** The report corresponding to the reportID in the route params */ transaction: transactionPropTypes, - /** The draft transaction of scan split bill */ - splitTransactionDraft: transactionPropTypes, - route: IOURequestStepRoutePropTypes.isRequired, }; const defaultProps = { forwardedRef: () => {}, transaction: {}, - splitTransactionDraft: {}, }; export default function (WrappedComponent) { @@ -35,7 +31,6 @@ export default function (WrappedComponent) { function WithFullTransactionOrNotFound({forwardedRef, ...props}) { const { transaction: {transactionID}, - splitTransactionDraft: {transactionID: splitTransactionDraftID}, } = props; const isFocused = useIsFocused(); @@ -43,7 +38,7 @@ export default function (WrappedComponent) { // If the transaction does not have a transactionID, then the transaction no longer exists in Onyx as a full transaction and the not-found page should be shown. // In addition, the not-found page should be shown only if the component screen's route is active (i.e. is focused). // This is to prevent it from showing when the modal is being dismissed while navigating to a different route (e.g. on requesting money). - if (!transactionID && !splitTransactionDraftID) { + if (!transactionID) { return ; } @@ -79,13 +74,5 @@ export default function (WrappedComponent) { return `${userAction === CONST.IOU.ACTION.CREATE ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; }, }, - splitTransactionDraft: { - key: ({route}) => { - const transactionID = lodashGet(route, 'params.transactionID', 0); - const userAction = lodashGet(route, 'params.action', CONST.IOU.ACTION.CREATE); - const isEditingSplitBill = userAction === CONST.IOU.ACTION.EDIT && lodashGet(route, 'params.iouType', CONST.IOU.TYPE.REQUEST) === CONST.IOU.TYPE.SPLIT; - return `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${isEditingSplitBill ? transactionID : '0'}`; - }, - }, })(WithFullTransactionOrNotFoundWithRef); } From 6438c074738652dc38b7c4558f013ace0acab14c Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 20 Feb 2024 00:08:33 +0700 Subject: [PATCH 14/23] rename variable --- .../MoneyRequestConfirmationList.js | 22 +++++++++++-------- .../request/step/IOURequestStepCategory.js | 11 +++++----- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 911532acb4fc..d389cc55238c 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -766,15 +766,19 @@ function MoneyRequestConfirmationList(props) { description={translate('common.category')} numberOfLinesTitle={2} onPress={() => { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( - CONST.IOU.ACTION.EDIT, - CONST.IOU.TYPE.SPLIT, - props.transaction.transactionID, - props.reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ); + if (props.isEditingSplitBill) { + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( + CONST.IOU.ACTION.EDIT, + props.iouType, + props.transaction.transactionID, + props.reportID, + Navigation.getActiveRouteWithoutParams(), + ), + ); + return; + } + Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID)); }} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index 9bd00a4e23aa..f945e537fd4c 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -50,8 +50,8 @@ function IOURequestStepCategory({ const styles = useThemeStyles(); const {translate} = useLocalize(); const isEditing = action === CONST.IOU.ACTION.EDIT; - const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT; - const {category: transactionCategory} = ReportUtils.getTransactionDetails(isEditing && isSplitBill ? splitDraftTransaction : transaction); + const isEditingSplitBill = isEditing && iouType === CONST.IOU.TYPE.SPLIT; + const {category: transactionCategory} = ReportUtils.getTransactionDetails(isEditingSplitBill ? splitDraftTransaction : transaction); const navigateBack = () => { Navigation.goBack(backTo); @@ -65,18 +65,19 @@ function IOURequestStepCategory({ const isSelectedCategory = category.searchText === transactionCategory; const updatedCategory = isSelectedCategory ? '' : category.searchText; - // The case edit split bill - if (isSplitBill && isEditing) { + // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value + if (isEditingSplitBill) { IOU.setDraftSplitTransaction(transaction.transactionID, {category: category.searchText}); navigateBack(); return; } - // The casse edit request + if (isEditing) { IOU.updateMoneyRequestCategory(transaction.transactionID, report.reportID, updatedCategory); Navigation.dismissModal(); return; } + IOU.setMoneyRequestCategory(transactionID, updatedCategory); navigateBack(); }; From 1786cdbdf72905f5d25b2512e4d9899fce52c8ed Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 20 Feb 2024 10:55:34 +0700 Subject: [PATCH 15/23] update param for update category function --- .../request/step/IOURequestStepCategory.js | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index f945e537fd4c..c15ef75def99 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -1,7 +1,10 @@ import lodashGet from 'lodash/get'; +import PropTypes from 'prop-types'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import CategoryPicker from '@components/CategoryPicker'; +import categoryPropTypes from '@components/categoryPropTypes'; +import tagPropTypes from '@components/tagPropTypes'; import Text from '@components/Text'; import transactionPropTypes from '@components/transactionPropTypes'; import useLocalize from '@hooks/useLocalize'; @@ -13,6 +16,7 @@ import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {policyPropTypes} from '@src/pages/workspace/withPolicy'; import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; import StepScreenWrapper from './StepScreenWrapper'; import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; @@ -31,12 +35,24 @@ const propTypes = { /** The report attached to the transaction */ report: reportPropTypes, + + /** The policy of the report */ + policy: policyPropTypes.policy, + + /** Collection of categories attached to a policy */ + policyCategories: PropTypes.objectOf(categoryPropTypes), + + /** Collection of tags attached to a policy */ + policyTags: tagPropTypes, }; const defaultProps = { report: {}, transaction: {}, splitDraftTransaction: {}, + policy: null, + policyTags: null, + policyCategories: null, }; function IOURequestStepCategory({ @@ -46,6 +62,9 @@ function IOURequestStepCategory({ }, transaction, splitDraftTransaction, + policy, + policyTags, + policyCategories, }) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -73,8 +92,8 @@ function IOURequestStepCategory({ } if (isEditing) { - IOU.updateMoneyRequestCategory(transaction.transactionID, report.reportID, updatedCategory); - Navigation.dismissModal(); + IOU.updateMoneyRequestCategory(transaction.transactionID, report.reportID, updatedCategory, policy, policyTags, policyCategories); + navigateBack(); return; } @@ -113,5 +132,14 @@ export default compose( return `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`; }, }, + policy: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`, + }, + policyCategories: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report ? report.policyID : '0'}`, + }, + policyTags: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, + }, }), )(IOURequestStepCategory); From adf9f13ceaba0c5bf0d9d0d3cdbf5a2d017753bc Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 20 Feb 2024 15:15:23 +0700 Subject: [PATCH 16/23] fix the case can not edit category --- src/pages/iou/request/step/IOURequestStepCategory.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index c15ef75def99..83e8e669993c 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -2,6 +2,8 @@ import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; +import _ from 'underscore'; +import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import CategoryPicker from '@components/CategoryPicker'; import categoryPropTypes from '@components/categoryPropTypes'; import tagPropTypes from '@components/tagPropTypes'; @@ -11,6 +13,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; +import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as ReportUtils from '@libs/ReportUtils'; import reportPropTypes from '@pages/reportPropTypes'; import * as IOU from '@userActions/IOU'; @@ -72,6 +75,9 @@ function IOURequestStepCategory({ const isEditingSplitBill = isEditing && iouType === CONST.IOU.TYPE.SPLIT; const {category: transactionCategory} = ReportUtils.getTransactionDetails(isEditingSplitBill ? splitDraftTransaction : transaction); + const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); + const shouldShowCategories = isPolicyExpenseChat && (transactionCategory || OptionsListUtils.hasEnabledOptions(_.values(policyCategories))); + const navigateBack = () => { Navigation.goBack(backTo); }; @@ -101,6 +107,10 @@ function IOURequestStepCategory({ navigateBack(); }; + if (!shouldShowCategories) { + return ; + } + return ( Date: Tue, 20 Feb 2024 16:16:29 +0700 Subject: [PATCH 17/23] move not found page into step screen wrapper --- src/pages/iou/request/step/IOURequestStepCategory.js | 6 +----- src/pages/iou/request/step/StepScreenWrapper.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index 83e8e669993c..1e70aaa43cbd 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -3,7 +3,6 @@ import PropTypes from 'prop-types'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import CategoryPicker from '@components/CategoryPicker'; import categoryPropTypes from '@components/categoryPropTypes'; import tagPropTypes from '@components/tagPropTypes'; @@ -107,15 +106,12 @@ function IOURequestStepCategory({ navigateBack(); }; - if (!shouldShowCategories) { - return ; - } - return ( {translate('iou.categorySelection')} diff --git a/src/pages/iou/request/step/StepScreenWrapper.js b/src/pages/iou/request/step/StepScreenWrapper.js index eae542f0f6f9..183db55ce42f 100644 --- a/src/pages/iou/request/step/StepScreenWrapper.js +++ b/src/pages/iou/request/step/StepScreenWrapper.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import {View} from 'react-native'; import _ from 'underscore'; +import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -23,6 +24,9 @@ const propTypes = { /** Whether or not the wrapper should be shown (sometimes screens can be embedded inside another screen that already is using a wrapper) */ shouldShowWrapper: PropTypes.bool.isRequired, + /** Whether or not display not found page */ + shouldShowNotFoundPage: PropTypes.bool, + /** An ID used for unit testing */ testID: PropTypes.string.isRequired, @@ -33,11 +37,16 @@ const propTypes = { const defaultProps = { onEntryTransitionEnd: () => {}, includeSafeAreaPaddingBottom: false, + shouldShowNotFoundPage: false, }; -function StepScreenWrapper({testID, headerTitle, onBackButtonPress, onEntryTransitionEnd, children, shouldShowWrapper, includeSafeAreaPaddingBottom}) { +function StepScreenWrapper({testID, headerTitle, onBackButtonPress, onEntryTransitionEnd, children, shouldShowWrapper, shouldShowNotFoundPage, includeSafeAreaPaddingBottom}) { const styles = useThemeStyles(); + if (shouldShowNotFoundPage) { + return ; + } + if (!shouldShowWrapper) { return children; } From b5c4658217f4ab69b610b74961fc5977d0a4d320 Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:47:28 +0700 Subject: [PATCH 18/23] Update src/pages/iou/request/step/StepScreenWrapper.js Co-authored-by: Amy Evans --- src/pages/iou/request/step/StepScreenWrapper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/StepScreenWrapper.js b/src/pages/iou/request/step/StepScreenWrapper.js index 183db55ce42f..1d9129861db0 100644 --- a/src/pages/iou/request/step/StepScreenWrapper.js +++ b/src/pages/iou/request/step/StepScreenWrapper.js @@ -24,7 +24,7 @@ const propTypes = { /** Whether or not the wrapper should be shown (sometimes screens can be embedded inside another screen that already is using a wrapper) */ shouldShowWrapper: PropTypes.bool.isRequired, - /** Whether or not display not found page */ + /** Whether or not to display not found page */ shouldShowNotFoundPage: PropTypes.bool, /** An ID used for unit testing */ From 248ebc045d251a8a928179a81c16fe288e32cdeb Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 22 Feb 2024 14:50:23 +0700 Subject: [PATCH 19/23] replace old function after merging main --- src/components/MoneyRequestConfirmationList.js | 2 +- src/pages/iou/request/step/IOURequestStepConfirmation.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index d389cc55238c..ba89b178ea85 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -778,7 +778,7 @@ function MoneyRequestConfirmationList(props) { ); return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID)); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(props.iouType, props.reportID)); }} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 98bb6851d0de..0744fbd600a7 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -133,7 +133,7 @@ function IOURequestStepConfirmation({ return; } if (policyCategories && policyCategories[transaction.category] && !policyCategories[transaction.category].enabled) { - IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID); + IOU.setMoneyRequestCategory(transactionID, ''); } }, [policyCategories, transaction.category, transactionID]); const defaultCategory = lodashGet( @@ -145,7 +145,7 @@ function IOURequestStepConfirmation({ if (requestType !== CONST.IOU.REQUEST_TYPE.DISTANCE || !_.isEmpty(transaction.category)) { return; } - IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, defaultCategory); + IOU.setMoneyRequestCategory(transactionID, defaultCategory); // Prevent resetting to default when unselect category // eslint-disable-next-line react-hooks/exhaustive-deps }, [transactionID, requestType, defaultCategory]); From fb86af91d3efb2f9164127123a27513a588b5a16 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 22 Feb 2024 14:53:11 +0700 Subject: [PATCH 20/23] revert incorrect change --- src/components/MoneyRequestConfirmationList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index ba89b178ea85..6507db78e456 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -778,7 +778,7 @@ function MoneyRequestConfirmationList(props) { ); return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(props.iouType, props.reportID)); + Navigation.navigate(ROUTES.MONEY_REQUEST_CATEGORY.getRoute(props.iouType, props.reportID)); }} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} From f93dda6550ab8cc6bc437afc409da4a595066e11 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 22 Feb 2024 15:23:08 +0700 Subject: [PATCH 21/23] remove the use of old route --- .../MoneyRequestConfirmationList.js | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 6507db78e456..2b18ab9bc003 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -766,19 +766,15 @@ function MoneyRequestConfirmationList(props) { description={translate('common.category')} numberOfLinesTitle={2} onPress={() => { - if (props.isEditingSplitBill) { - Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( - CONST.IOU.ACTION.EDIT, - props.iouType, - props.transaction.transactionID, - props.reportID, - Navigation.getActiveRouteWithoutParams(), - ), - ); - return; - } - Navigation.navigate(ROUTES.MONEY_REQUEST_CATEGORY.getRoute(props.iouType, props.reportID)); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute( + CONST.IOU.ACTION.EDIT, + props.iouType, + props.transaction.transactionID, + props.reportID, + Navigation.getActiveRouteWithoutParams(), + ), + ); }} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} From 60c559d44815d74eb97024430230a73bbf796fcc Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 22 Feb 2024 17:11:26 +0700 Subject: [PATCH 22/23] rename variable --- src/pages/iou/request/step/IOURequestStepCategory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index 1e70aaa43cbd..f7d25e1a1d48 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -75,7 +75,7 @@ function IOURequestStepCategory({ const {category: transactionCategory} = ReportUtils.getTransactionDetails(isEditingSplitBill ? splitDraftTransaction : transaction); const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); - const shouldShowCategories = isPolicyExpenseChat && (transactionCategory || OptionsListUtils.hasEnabledOptions(_.values(policyCategories))); + const shouldShowNotFoundPage = !isPolicyExpenseChat || (!transactionCategory && !OptionsListUtils.hasEnabledOptions(_.values(policyCategories))); const navigateBack = () => { Navigation.goBack(backTo); @@ -111,7 +111,7 @@ function IOURequestStepCategory({ headerTitle={translate('common.category')} onBackButtonPress={navigateBack} shouldShowWrapper - shouldShowNotFoundPage={!shouldShowCategories} + shouldShowNotFoundPage={shouldShowNotFoundPage} testID={IOURequestStepCategory.displayName} > {translate('iou.categorySelection')} From c79efb5a42a21ba94242289e9e8588d3e2937f46 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 22 Feb 2024 17:37:11 +0700 Subject: [PATCH 23/23] fix lint --- src/pages/iou/request/step/IOURequestStepCategory.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/request/step/IOURequestStepCategory.js b/src/pages/iou/request/step/IOURequestStepCategory.js index f7d25e1a1d48..3e0feec02854 100644 --- a/src/pages/iou/request/step/IOURequestStepCategory.js +++ b/src/pages/iou/request/step/IOURequestStepCategory.js @@ -75,6 +75,7 @@ function IOURequestStepCategory({ const {category: transactionCategory} = ReportUtils.getTransactionDetails(isEditingSplitBill ? splitDraftTransaction : transaction); const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report); + // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = !isPolicyExpenseChat || (!transactionCategory && !OptionsListUtils.hasEnabledOptions(_.values(policyCategories))); const navigateBack = () => {