From 199a826e0e592b395cb644253e770f8f754ec302 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 25 Jan 2024 15:29:36 +0700 Subject: [PATCH 01/23] fix Remove old description page --- src/ROUTES.ts | 10 +- src/SCREENS.ts | 1 - .../MoneyRequestConfirmationList.js | 13 +- ...oraryForRefactorRequestConfirmationList.js | 12 +- .../ReportActionItem/MoneyRequestView.js | 12 +- .../AppNavigator/ModalStackNavigators.tsx | 1 - src/libs/Navigation/linkingConfig.ts | 1 - src/libs/Navigation/types.ts | 3 +- src/libs/actions/IOU.js | 5 +- src/pages/EditRequestDescriptionPage.js | 91 ---------- src/pages/EditRequestPage.js | 45 ++--- src/pages/EditSplitBillPage.js | 29 +-- src/pages/iou/MoneyRequestDescriptionPage.js | 165 ------------------ .../request/step/IOURequestStepDescription.js | 6 +- 14 files changed, 74 insertions(+), 320 deletions(-) delete mode 100644 src/pages/EditRequestDescriptionPage.js delete mode 100644 src/pages/iou/MoneyRequestDescriptionPage.js diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 9c4375b84ab6..6849585b4aa2 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -279,10 +279,6 @@ const ROUTES = { route: ':iouType/new/currency/:reportID?', getRoute: (iouType: string, reportID: string, currency: string, backTo: string) => `${iouType}/new/currency/${reportID}?currency=${currency}&backTo=${backTo}` as const, }, - MONEY_REQUEST_DESCRIPTION: { - 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, @@ -349,9 +345,9 @@ const ROUTES = { getUrlWithBackToParam(`create/${iouType}/date/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_DESCRIPTION: { - route: 'create/:iouType/description/:transactionID/:reportID', - getRoute: (iouType: ValueOf, transactionID: string, reportID: string, backTo = '') => - getUrlWithBackToParam(`create/${iouType}/description/${transactionID}/${reportID}`, backTo), + route: ':action/:iouType/description/:transactionID/:reportID', + getRoute: (action: ValueOf, iouType: ValueOf, transactionID: string, reportID: string, backTo = '') => + getUrlWithBackToParam(`${action}/${iouType}/description/${transactionID}/${reportID}`, backTo), }, MONEY_REQUEST_STEP_DISTANCE: { route: 'create/:iouType/distance/:transactionID/:reportID', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 2bf40caede57..cee5d6e8f40b 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -144,7 +144,6 @@ const SCREENS = { CONFIRMATION: 'Money_Request_Confirmation', CURRENCY: 'Money_Request_Currency', DATE: 'Money_Request_Date', - DESCRIPTION: 'Money_Request_Description', CATEGORY: 'Money_Request_Category', TAG: 'Money_Request_Tag', MERCHANT: 'Money_Request_Merchant', diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 590154b48bca..1544ead61dd4 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -663,11 +663,18 @@ function MoneyRequestConfirmationList(props) { title={props.iouComment} description={translate('common.description')} onPress={() => { - if (props.isEditingSplitBill) { - Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION)); + if (!props.isEditingSplitBill) { return; } - Navigation.navigate(ROUTES.MONEY_REQUEST_DESCRIPTION.getRoute(props.iouType, props.reportID)); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute( + CONST.IOU.ACTION.EDIT, + CONST.IOU.TYPE.SPLIT, + 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..21824ee69813 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -691,11 +691,9 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ title={iouComment} description={translate('common.description')} onPress={() => { - if (isEditingSplitBill) { - Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION)); - return; - } - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()), + ); }} style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} @@ -711,10 +709,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => { - if (isEditingSplitBill) { - Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID, CONST.EDIT_REQUEST_FIELD.MERCHANT)); - return; - } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} disabled={didConfirm} diff --git a/src/components/ReportActionItem/MoneyRequestView.js b/src/components/ReportActionItem/MoneyRequestView.js index 3121328138ee..46e564926936 100644 --- a/src/components/ReportActionItem/MoneyRequestView.js +++ b/src/components/ReportActionItem/MoneyRequestView.js @@ -286,7 +286,17 @@ 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.DESCRIPTION))} + onPress={() => + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute( + CONST.IOU.ACTION.EDIT, + CONST.IOU.TYPE.REQUEST, + transaction.transactionID, + report.reportID, + Navigation.getActiveRouteWithoutParams(), + ), + ) + } wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} brickRoadIndicator={hasViolations('comment') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''} numberOfLinesTitle={0} diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index c9325206e5b2..881597a827ee 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -96,7 +96,6 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator require('../../../pages/iou/steps/MoneyRequestConfirmPage').default as React.ComponentType, [SCREENS.MONEY_REQUEST.CURRENCY]: () => 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, diff --git a/src/libs/Navigation/linkingConfig.ts b/src/libs/Navigation/linkingConfig.ts index 5df2bcf0e57b..56d9d362ffb6 100644 --- a/src/libs/Navigation/linkingConfig.ts +++ b/src/libs/Navigation/linkingConfig.ts @@ -431,7 +431,6 @@ const linkingConfig: LinkingOptions = { [SCREENS.MONEY_REQUEST.CONFIRMATION]: ROUTES.MONEY_REQUEST_CONFIRMATION.route, [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, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 2371c764f42a..5cf2220c304a 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -201,7 +201,8 @@ type MoneyRequestNavigatorParamList = { field: string; threadReportID: string; }; - [SCREENS.MONEY_REQUEST.DESCRIPTION]: { + [SCREENS.MONEY_REQUEST.STEP_DESCRIPTION]: { + action: string; iouType: string; reportID: string; field: string; diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index eb9541edcad2..c15c24c61e72 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -201,9 +201,10 @@ function setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency) { /** * @param {String} transactionID * @param {String} comment + * @param {Boolean} isDraft */ -function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {comment: {comment: comment.trim()}}); +function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment, isDraft) { + Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {comment: {comment: comment.trim()}}); } /** diff --git a/src/pages/EditRequestDescriptionPage.js b/src/pages/EditRequestDescriptionPage.js deleted file mode 100644 index 9b2a9e465746..000000000000 --- a/src/pages/EditRequestDescriptionPage.js +++ /dev/null @@ -1,91 +0,0 @@ -import {useFocusEffect} from '@react-navigation/native'; -import PropTypes from 'prop-types'; -import React, {useCallback, useRef} from 'react'; -import {View} from 'react-native'; -import FormProvider from '@components/Form/FormProvider'; -import InputWrapperWithRef from '@components/Form/InputWrapper'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import TextInput from '@components/TextInput'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import * as Browser from '@libs/Browser'; -import updateMultilineInputRange from '@libs/updateMultilineInputRange'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; - -const propTypes = { - /** Transaction default description value */ - defaultDescription: PropTypes.string.isRequired, - - /** Callback to fire when the Save button is pressed */ - onSubmit: PropTypes.func.isRequired, -}; - -function EditRequestDescriptionPage({defaultDescription, onSubmit}) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - const descriptionInputRef = useRef(null); - const focusTimeoutRef = useRef(null); - - useFocusEffect( - useCallback(() => { - focusTimeoutRef.current = setTimeout(() => { - if (descriptionInputRef.current) { - descriptionInputRef.current.focus(); - } - return () => { - if (!focusTimeoutRef.current) { - return; - } - clearTimeout(focusTimeoutRef.current); - }; - }, CONST.ANIMATED_TRANSITION); - }, []), - ); - - return ( - - - - - { - if (!el) { - return; - } - descriptionInputRef.current = el; - updateMultilineInputRange(descriptionInputRef.current); - }} - autoGrowHeight - containerStyles={[styles.autoGrowHeightMultilineInput]} - submitOnEnter={!Browser.isMobile()} - /> - - - - ); -} - -EditRequestDescriptionPage.propTypes = propTypes; -EditRequestDescriptionPage.displayName = 'EditRequestDescriptionPage'; - -export default EditRequestDescriptionPage; diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index 3eb9d88f1120..b57d65726389 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -22,7 +22,7 @@ import ROUTES from '@src/ROUTES'; import EditRequestAmountPage from './EditRequestAmountPage'; import EditRequestCategoryPage from './EditRequestCategoryPage'; import EditRequestCreatedPage from './EditRequestCreatedPage'; -import EditRequestDescriptionPage from './EditRequestDescriptionPage'; +// import EditRequestDescriptionPage from './EditRequestDescriptionPage'; import EditRequestDistancePage from './EditRequestDistancePage'; import EditRequestMerchantPage from './EditRequestMerchantPage'; import EditRequestReceiptPage from './EditRequestReceiptPage'; @@ -74,7 +74,7 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep const { amount: transactionAmount, currency: transactionCurrency, - comment: transactionDescription, + // comment: transactionDescription, merchant: transactionMerchant, category: transactionCategory, tag: transactionTag, @@ -180,25 +180,28 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep [transactionCategory, transaction.transactionID, report.reportID], ); - const saveComment = useCallback( - ({comment: newComment}) => { - // Only update comment if it has changed - if (newComment.trim() !== transactionDescription) { - IOU.updateMoneyRequestDescription(transaction.transactionID, report.reportID, newComment.trim()); - } - Navigation.dismissModal(); - }, - [transactionDescription, transaction.transactionID, report.reportID], - ); - - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) { - return ( - - ); - } + // I removed EditRequestDescriptionPage because we won't use this component anymore. This page EditRequestPage also be removed in https://github.com/Expensify/App/issues/29107 + + // const saveComment = useCallback( + // ({comment: newComment}) => { + // // Only update comment if it has changed + // if (newComment.trim() !== transactionDescription) { + // IOU.updateMoneyRequestDescription(transaction.transactionID, report.reportID, newComment.trim()); + // } + // Navigation.dismissModal(); + // }, + // [transactionDescription, transaction.transactionID, report.reportID], + // ); + + // + // if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) { + // return ( + // + // ); + // } if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DATE) { return ( diff --git a/src/pages/EditSplitBillPage.js b/src/pages/EditSplitBillPage.js index 2be8d6f683ee..69416e87bb9b 100644 --- a/src/pages/EditSplitBillPage.js +++ b/src/pages/EditSplitBillPage.js @@ -15,7 +15,7 @@ import ROUTES from '@src/ROUTES'; import EditRequestAmountPage from './EditRequestAmountPage'; import EditRequestCategoryPage from './EditRequestCategoryPage'; import EditRequestCreatedPage from './EditRequestCreatedPage'; -import EditRequestDescriptionPage from './EditRequestDescriptionPage'; +// import EditRequestDescriptionPage from './EditRequestDescriptionPage'; import EditRequestMerchantPage from './EditRequestMerchantPage'; import EditRequestTagPage from './EditRequestTagPage'; import reportPropTypes from './reportPropTypes'; @@ -58,7 +58,7 @@ function EditSplitBillPage({route, transaction, draftTransaction, report}) { const { amount: transactionAmount, currency: transactionCurrency, - comment: transactionDescription, + // comment: transactionDescription, merchant: transactionMerchant, created: transactionCreated, category: transactionCategory, @@ -76,18 +76,19 @@ function EditSplitBillPage({route, transaction, draftTransaction, report}) { navigateBackToSplitDetails(); }; - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) { - return ( - { - setDraftSplitTransaction({ - comment: transactionChanges.comment.trim(), - }); - }} - /> - ); - } + // I removed EditRequestDescriptionPage because we won't use this component anymore. This page EditSplitBillPage also be removed in https://github.com/Expensify/App/issues/29107 + // if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) { + // return ( + // { + // setDraftSplitTransaction({ + // comment: transactionChanges.comment.trim(), + // }); + // }} + // /> + // ); + // } if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DATE) { return ( diff --git a/src/pages/iou/MoneyRequestDescriptionPage.js b/src/pages/iou/MoneyRequestDescriptionPage.js deleted file mode 100644 index fe3100b8c3bd..000000000000 --- a/src/pages/iou/MoneyRequestDescriptionPage.js +++ /dev/null @@ -1,165 +0,0 @@ -import {useFocusEffect} from '@react-navigation/native'; -import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; -import React, {useCallback, useEffect, useRef} from 'react'; -import {View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; -import _ from 'underscore'; -import FormProvider from '@components/Form/FormProvider'; -import InputWrapperWithRef from '@components/Form/InputWrapper'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import TextInput from '@components/TextInput'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import * as IOU from '@libs/actions/IOU'; -import * as Browser from '@libs/Browser'; -import * as MoneyRequestUtils from '@libs/MoneyRequestUtils'; -import Navigation from '@libs/Navigation/Navigation'; -import updateMultilineInputRange from '@libs/updateMultilineInputRange'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import {iouDefaultProps, iouPropTypes} from './propTypes'; - -const propTypes = { - /** Onyx Props */ - /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ - iou: iouPropTypes, - - /** Route from navigation */ - route: PropTypes.shape({ - /** Params from the route */ - 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, - - /** Which field we are editing */ - field: PropTypes.string, - - /** reportID for the "transaction thread" */ - threadReportID: PropTypes.string, - }), - }).isRequired, - - /** The current tab we have navigated to in the request modal. String that corresponds to the request type. */ - selectedTab: PropTypes.oneOf(_.values(CONST.TAB_REQUEST)), -}; - -const defaultProps = { - iou: iouDefaultProps, - selectedTab: '', -}; - -function MoneyRequestDescriptionPage({iou, route, selectedTab}) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - const inputRef = useRef(null); - const focusTimeoutRef = useRef(null); - const iouType = lodashGet(route, 'params.iouType', ''); - const reportID = lodashGet(route, 'params.reportID', ''); - const isDistanceRequest = MoneyRequestUtils.isDistanceRequest(iouType, selectedTab); - - useFocusEffect( - useCallback(() => { - focusTimeoutRef.current = setTimeout(() => { - if (inputRef.current) { - inputRef.current.focus(); - } - return () => { - if (!focusTimeoutRef.current) { - return; - } - clearTimeout(focusTimeoutRef.current); - }; - }, CONST.ANIMATED_TRANSITION); - }, []), - ); - - useEffect(() => { - const moneyRequestId = `${iouType}${reportID}`; - const shouldReset = iou.id !== moneyRequestId; - if (shouldReset) { - IOU.resetMoneyRequestInfo(moneyRequestId); - } - - if (!isDistanceRequest && (_.isEmpty(iou.participants) || (iou.amount === 0 && !iou.receiptPath) || shouldReset)) { - Navigation.goBack(ROUTES.MONEY_REQUEST.getRoute(iouType, reportID), true); - } - }, [iou.id, iou.participants, iou.amount, iou.receiptPath, iouType, reportID, isDistanceRequest]); - - function navigateBack() { - Navigation.goBack(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, reportID)); - } - - /** - * Sets the money request comment by saving it to Onyx. - * - * @param {Object} value - * @param {String} value.moneyRequestComment - */ - function updateComment(value) { - IOU.setMoneyRequestDescription(value.moneyRequestComment); - navigateBack(); - } - - return ( - - <> - navigateBack()} - /> - updateComment(value)} - submitButtonText={translate('common.save')} - enabledWhenOffline - > - - { - if (!el) { - return; - } - inputRef.current = el; - updateMultilineInputRange(inputRef.current); - }} - autoGrowHeight - containerStyles={[styles.autoGrowHeightMultilineInput]} - submitOnEnter={!Browser.isMobile()} - /> - - - - - ); -} - -MoneyRequestDescriptionPage.propTypes = propTypes; -MoneyRequestDescriptionPage.defaultProps = defaultProps; -MoneyRequestDescriptionPage.displayName = 'MoneyRequestDescriptionPage'; - -export default withOnyx({ - iou: { - key: ONYXKEYS.IOU, - }, - selectedTab: { - key: `${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.RECEIPT_TAB_ID}`, - }, -})(MoneyRequestDescriptionPage); diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 849f3276667e..c7c0260b6a3f 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -36,7 +36,7 @@ const defaultProps = { function IOURequestStepDescription({ route: { - params: {transactionID, backTo}, + params: {action, transactionID, backTo}, }, transaction, }) { @@ -44,7 +44,7 @@ function IOURequestStepDescription({ const {translate} = useLocalize(); const inputRef = useRef(null); const focusTimeoutRef = useRef(null); - + const isDraft = action === CONST.IOU.ACTION.CREATE; useFocusEffect( useCallback(() => { focusTimeoutRef.current = setTimeout(() => { @@ -70,7 +70,7 @@ function IOURequestStepDescription({ * @param {String} value.moneyRequestComment */ const updateComment = (value) => { - IOU.setMoneyRequestDescription_temporaryForRefactor(transactionID, value.moneyRequestComment); + IOU.setMoneyRequestDescription_temporaryForRefactor(transactionID, value.moneyRequestComment, isDraft); navigateBack(); }; From c983c5fac2addd7a03fe2241029f8cd7f1f3853b Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 25 Jan 2024 15:55:07 +0700 Subject: [PATCH 02/23] move change from old description page to new one --- src/pages/iou/request/step/IOURequestStepDescription.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index c7c0260b6a3f..06a64adcf650 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -96,7 +96,7 @@ function IOURequestStepDescription({ defaultValue={lodashGet(transaction, 'comment.comment', '')} label={translate('moneyRequestConfirmationList.whatsItFor')} accessibilityLabel={translate('moneyRequestConfirmationList.whatsItFor')} - role={CONST.ACCESSIBILITY_ROLE.TEXT} + role={CONST.ROLE.PRESENTATION} ref={(el) => { if (!el) { return; @@ -106,7 +106,6 @@ function IOURequestStepDescription({ }} autoGrowHeight containerStyles={[styles.autoGrowHeightMultilineInput]} - inputStyle={[styles.verticalAlignTop]} submitOnEnter={!Browser.isMobile()} /> From d93929e61cc8f36c48ac9bc07b0a1d1035b2b8b6 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 25 Jan 2024 17:19:50 +0700 Subject: [PATCH 03/23] update logic to save description in each case --- src/libs/actions/IOU.js | 5 ++--- .../request/step/IOURequestStepDescription.js | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index c15c24c61e72..eb9541edcad2 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -201,10 +201,9 @@ function setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency) { /** * @param {String} transactionID * @param {String} comment - * @param {Boolean} isDraft */ -function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment, isDraft) { - Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {comment: {comment: comment.trim()}}); +function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment) { + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {comment: {comment: comment.trim()}}); } /** diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 06a64adcf650..72d249a964f4 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -36,7 +36,7 @@ const defaultProps = { function IOURequestStepDescription({ route: { - params: {action, transactionID, backTo}, + params: {action,iouType, transactionID, reportID, backTo}, }, transaction, }) { @@ -70,7 +70,22 @@ function IOURequestStepDescription({ * @param {String} value.moneyRequestComment */ const updateComment = (value) => { - IOU.setMoneyRequestDescription_temporaryForRefactor(transactionID, value.moneyRequestComment, isDraft); + const newComment = value.moneyRequestComment + // Only update comment if it has changed + if (newComment.trim() !== lodashGet(transaction, 'comment.comment', '')) { + if (isDraft) { + IOU.setMoneyRequestDescription_temporaryForRefactor(transactionID, newComment, isDraft); + } else { + if (iouType ===CONST.IOU.TYPE.REQUEST) { + IOU.updateMoneyRequestDescription(transaction.transactionID, reportID, newComment.trim()); + } + if (iouType ===CONST.IOU.TYPE.SPLIT) { + IOU.setDraftSplitTransaction(transaction.transactionID, { + comment: newComment.trim() + }) + } + } + } navigateBack(); }; From e6901038e62a0ff3e640c54d328e54cdba580e37 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 25 Jan 2024 17:50:43 +0700 Subject: [PATCH 04/23] fix lint --- .../iou/request/step/IOURequestStepDescription.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 72d249a964f4..650380d4615a 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -36,7 +36,7 @@ const defaultProps = { function IOURequestStepDescription({ route: { - params: {action,iouType, transactionID, reportID, backTo}, + params: {action, iouType, transactionID, reportID, backTo}, }, transaction, }) { @@ -70,19 +70,19 @@ function IOURequestStepDescription({ * @param {String} value.moneyRequestComment */ const updateComment = (value) => { - const newComment = value.moneyRequestComment + const newComment = value.moneyRequestComment; // Only update comment if it has changed if (newComment.trim() !== lodashGet(transaction, 'comment.comment', '')) { if (isDraft) { IOU.setMoneyRequestDescription_temporaryForRefactor(transactionID, newComment, isDraft); } else { - if (iouType ===CONST.IOU.TYPE.REQUEST) { + if (iouType === CONST.IOU.TYPE.REQUEST) { IOU.updateMoneyRequestDescription(transaction.transactionID, reportID, newComment.trim()); } - if (iouType ===CONST.IOU.TYPE.SPLIT) { + if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.setDraftSplitTransaction(transaction.transactionID, { - comment: newComment.trim() - }) + comment: newComment.trim(), + }); } } } From f1de3f2482f11bf9350ff32bf88e658ff28c6b70 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 25 Jan 2024 18:14:38 +0700 Subject: [PATCH 05/23] fix remove redandunt changr --- .../MoneyTemporaryForRefactorRequestConfirmationList.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js index 21824ee69813..ee7a02e58527 100755 --- a/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js +++ b/src/components/MoneyTemporaryForRefactorRequestConfirmationList.js @@ -709,6 +709,10 @@ function MoneyTemporaryForRefactorRequestConfirmationList({ style={[styles.moneyRequestMenuItem]} titleStyle={styles.flex1} onPress={() => { + if (isEditingSplitBill) { + Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID, CONST.EDIT_REQUEST_FIELD.MERCHANT)); + return; + } Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams())); }} disabled={didConfirm} From 61632f52e24a3363119c5657824c559c2b9ea96a Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 27 Jan 2024 11:18:25 +0700 Subject: [PATCH 06/23] move logic to IOU.js --- src/libs/actions/IOU.js | 32 ++++++++++++++----- .../request/step/IOURequestStepDescription.js | 20 ++---------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index eb9541edcad2..73d90d1a5e8c 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -198,14 +198,6 @@ function setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {currency}); } -/** - * @param {String} transactionID - * @param {String} comment - */ -function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {comment: {comment: comment.trim()}}); -} - /** * @param {String} transactionID * @param {String} merchant @@ -3698,6 +3690,30 @@ function getIOUReportID(iou, route) { return lodashGet(route, 'params.reportID') || lodashGet(iou, 'participants.0.reportID', ''); } +/** + * @param {Object} transaction + * @param {String} comment + * @param {Boolean} isDraft + * @param {String} iouType + * @param {String} reportID + */ +function setMoneyRequestDescription_temporaryForRefactor(transaction, comment, isDraft, iouType, reportID) { + // Only update comment if it has changed + if (comment.trim() === lodashGet(transaction, 'comment.comment', '')) { + return; + } + if (isDraft) { + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transaction.transactionID}`, {comment: {comment}}); + } else { + if (iouType === CONST.IOU.TYPE.REQUEST) { + updateMoneyRequestDescription(transaction.transactionID, reportID, comment); + } + if (iouType === CONST.IOU.TYPE.SPLIT) { + setDraftSplitTransaction(transaction.transactionID, {comment}); + } + } +} + export { setMoneyRequestParticipants, createDistanceRequest, diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 650380d4615a..ea16219fc380 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -36,7 +36,7 @@ const defaultProps = { function IOURequestStepDescription({ route: { - params: {action, iouType, transactionID, reportID, backTo}, + params: {action, iouType, reportID, backTo}, }, transaction, }) { @@ -70,22 +70,8 @@ function IOURequestStepDescription({ * @param {String} value.moneyRequestComment */ const updateComment = (value) => { - const newComment = value.moneyRequestComment; - // Only update comment if it has changed - if (newComment.trim() !== lodashGet(transaction, 'comment.comment', '')) { - if (isDraft) { - IOU.setMoneyRequestDescription_temporaryForRefactor(transactionID, newComment, isDraft); - } else { - if (iouType === CONST.IOU.TYPE.REQUEST) { - IOU.updateMoneyRequestDescription(transaction.transactionID, reportID, newComment.trim()); - } - if (iouType === CONST.IOU.TYPE.SPLIT) { - IOU.setDraftSplitTransaction(transaction.transactionID, { - comment: newComment.trim(), - }); - } - } - } + const newComment = value.moneyRequestComment.trim(); + IOU.setMoneyRequestDescription_temporaryForRefactor(transaction, newComment, isDraft, iouType, reportID); navigateBack(); }; From da8f7602cc7e72130d172b0b818e34b6cc592dc3 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sun, 28 Jan 2024 15:09:06 +0700 Subject: [PATCH 07/23] remove comment --- src/pages/EditRequestPage.js | 23 ----------------------- src/pages/EditSplitBillPage.js | 14 -------------- 2 files changed, 37 deletions(-) diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index b57d65726389..6277dc64b874 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -180,29 +180,6 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep [transactionCategory, transaction.transactionID, report.reportID], ); - // I removed EditRequestDescriptionPage because we won't use this component anymore. This page EditRequestPage also be removed in https://github.com/Expensify/App/issues/29107 - - // const saveComment = useCallback( - // ({comment: newComment}) => { - // // Only update comment if it has changed - // if (newComment.trim() !== transactionDescription) { - // IOU.updateMoneyRequestDescription(transaction.transactionID, report.reportID, newComment.trim()); - // } - // Navigation.dismissModal(); - // }, - // [transactionDescription, transaction.transactionID, report.reportID], - // ); - - // - // if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) { - // return ( - // - // ); - // } - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DATE) { return ( { - // setDraftSplitTransaction({ - // comment: transactionChanges.comment.trim(), - // }); - // }} - // /> - // ); - // } - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DATE) { return ( Date: Mon, 29 Jan 2024 12:15:26 +0700 Subject: [PATCH 08/23] remove comment --- src/libs/actions/IOU.js | 14 +++++--------- src/pages/EditRequestPage.js | 2 -- src/pages/EditSplitBillPage.js | 2 -- .../iou/request/step/IOURequestStepDescription.js | 5 ++++- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index fb9e7252a4c5..89edcb6438c8 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -3716,25 +3716,21 @@ function getIOUReportID(iou, route) { } /** - * @param {Object} transaction + * @param {String} transactionID * @param {String} comment * @param {Boolean} isDraft * @param {String} iouType * @param {String} reportID */ -function setMoneyRequestDescription_temporaryForRefactor(transaction, comment, isDraft, iouType, reportID) { - // Only update comment if it has changed - if (comment.trim() === lodashGet(transaction, 'comment.comment', '')) { - return; - } +function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment, isDraft, iouType, reportID) { if (isDraft) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transaction.transactionID}`, {comment: {comment}}); + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {comment: {comment}}); } else { if (iouType === CONST.IOU.TYPE.REQUEST) { - updateMoneyRequestDescription(transaction.transactionID, reportID, comment); + updateMoneyRequestDescription(transactionID, reportID, comment); } if (iouType === CONST.IOU.TYPE.SPLIT) { - setDraftSplitTransaction(transaction.transactionID, {comment}); + setDraftSplitTransaction(transactionID, {comment}); } } } diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index 6277dc64b874..7e1a9f7d9b7b 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -22,7 +22,6 @@ import ROUTES from '@src/ROUTES'; import EditRequestAmountPage from './EditRequestAmountPage'; import EditRequestCategoryPage from './EditRequestCategoryPage'; import EditRequestCreatedPage from './EditRequestCreatedPage'; -// import EditRequestDescriptionPage from './EditRequestDescriptionPage'; import EditRequestDistancePage from './EditRequestDistancePage'; import EditRequestMerchantPage from './EditRequestMerchantPage'; import EditRequestReceiptPage from './EditRequestReceiptPage'; @@ -74,7 +73,6 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep const { amount: transactionAmount, currency: transactionCurrency, - // comment: transactionDescription, merchant: transactionMerchant, category: transactionCategory, tag: transactionTag, diff --git a/src/pages/EditSplitBillPage.js b/src/pages/EditSplitBillPage.js index 1d4dff90d490..1243095a3701 100644 --- a/src/pages/EditSplitBillPage.js +++ b/src/pages/EditSplitBillPage.js @@ -15,7 +15,6 @@ import ROUTES from '@src/ROUTES'; import EditRequestAmountPage from './EditRequestAmountPage'; import EditRequestCategoryPage from './EditRequestCategoryPage'; import EditRequestCreatedPage from './EditRequestCreatedPage'; -// import EditRequestDescriptionPage from './EditRequestDescriptionPage'; import EditRequestMerchantPage from './EditRequestMerchantPage'; import EditRequestTagPage from './EditRequestTagPage'; import reportPropTypes from './reportPropTypes'; @@ -58,7 +57,6 @@ function EditSplitBillPage({route, transaction, draftTransaction, report}) { const { amount: transactionAmount, currency: transactionCurrency, - // comment: transactionDescription, merchant: transactionMerchant, created: transactionCreated, category: transactionCategory, diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index ea16219fc380..1be4965de1e4 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -71,7 +71,10 @@ function IOURequestStepDescription({ */ const updateComment = (value) => { const newComment = value.moneyRequestComment.trim(); - IOU.setMoneyRequestDescription_temporaryForRefactor(transaction, newComment, isDraft, iouType, reportID); + // Only update comment if it has changed + if (newComment !== lodashGet(transaction, 'comment.comment', '')) { + IOU.setMoneyRequestDescription_temporaryForRefactor(transaction.transactionID, newComment, isDraft, iouType, reportID); + } navigateBack(); }; From 481119fccc7e85675891f627e1fdce58e8791fb5 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 30 Jan 2024 11:39:19 +0700 Subject: [PATCH 09/23] update logic split flow --- src/libs/actions/IOU.js | 29 ++++++------------- .../request/step/IOURequestStepDescription.js | 14 ++++++++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 89edcb6438c8..0911c3a377c8 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -199,6 +199,15 @@ function setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {currency}); } +/** + * @param {String} transactionID + * @param {String} comment + * @param {Boolean} isDraft + */ +function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment, isDraft) { + Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {comment: {comment: comment.trim()}}); +} + /** * @param {String} transactionID * @param {String} merchant @@ -3715,26 +3724,6 @@ function getIOUReportID(iou, route) { return lodashGet(route, 'params.reportID') || lodashGet(iou, 'participants.0.reportID', ''); } -/** - * @param {String} transactionID - * @param {String} comment - * @param {Boolean} isDraft - * @param {String} iouType - * @param {String} reportID - */ -function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment, isDraft, iouType, reportID) { - if (isDraft) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {comment: {comment}}); - } else { - if (iouType === CONST.IOU.TYPE.REQUEST) { - updateMoneyRequestDescription(transactionID, reportID, comment); - } - if (iouType === CONST.IOU.TYPE.SPLIT) { - setDraftSplitTransaction(transactionID, {comment}); - } - } -} - /** * @param {String} receiptFilename * @param {String} receiptPath diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 1be4965de1e4..fda51b113a96 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -73,7 +73,19 @@ function IOURequestStepDescription({ const newComment = value.moneyRequestComment.trim(); // Only update comment if it has changed if (newComment !== lodashGet(transaction, 'comment.comment', '')) { - IOU.setMoneyRequestDescription_temporaryForRefactor(transaction.transactionID, newComment, isDraft, iouType, reportID); + if (iouType === CONST.IOU.TYPE.REQUEST) { + IOU.setMoneyRequestDescription_temporaryForRefactor(transaction.transactionID, newComment, isDraft); + if (isDraft) { + IOU.updateMoneyRequestDescription(transaction.transactionID, reportID, newComment); + } + } + if (iouType === CONST.IOU.TYPE.SPLIT) { + if (isDraft) { + IOU.setMoneyRequestDescription_temporaryForRefactor(transaction.transactionID, newComment, isDraft); + } else { + IOU.setDraftSplitTransaction(transaction.transactionID, {newComment}); + } + } } navigateBack(); }; From 1c4544110b4968d5d00c1973d8d6fef2de7c6dc7 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 30 Jan 2024 17:40:23 +0700 Subject: [PATCH 10/23] early return and update name --- src/libs/actions/IOU.js | 12 ++-------- .../request/step/IOURequestStepDescription.js | 24 ++++++++++--------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 4c1526a61ea7..9870877c1229 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -204,7 +204,7 @@ function setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency) { * @param {String} comment * @param {Boolean} isDraft */ -function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment, isDraft) { +function setMoneyRequestDescription(transactionID, comment, isDraft) { Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {comment: {comment: comment.trim()}}); } @@ -3587,13 +3587,6 @@ function setMoneyRequestCurrency(currency) { Onyx.merge(ONYXKEYS.IOU, {currency}); } -/** - * @param {String} comment - */ -function setMoneyRequestDescription(comment) { - Onyx.merge(ONYXKEYS.IOU, {comment: comment.trim()}); -} - /** * @param {String} merchant */ @@ -3780,7 +3773,7 @@ export { setMoneyRequestCategory_temporaryForRefactor, setMoneyRequestCreated_temporaryForRefactor, setMoneyRequestCurrency_temporaryForRefactor, - setMoneyRequestDescription_temporaryForRefactor, + setMoneyRequestDescription, setMoneyRequestMerchant_temporaryForRefactor, setMoneyRequestParticipants_temporaryForRefactor, setMoneyRequestReceipt, @@ -3790,7 +3783,6 @@ export { setMoneyRequestCategory, setMoneyRequestCreated, setMoneyRequestCurrency, - setMoneyRequestDescription, setMoneyRequestId, setMoneyRequestMerchant, setMoneyRequestParticipantsFromReport, diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index fda51b113a96..51e6737173e2 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -73,18 +73,20 @@ function IOURequestStepDescription({ const newComment = value.moneyRequestComment.trim(); // Only update comment if it has changed if (newComment !== lodashGet(transaction, 'comment.comment', '')) { - if (iouType === CONST.IOU.TYPE.REQUEST) { - IOU.setMoneyRequestDescription_temporaryForRefactor(transaction.transactionID, newComment, isDraft); - if (isDraft) { - IOU.updateMoneyRequestDescription(transaction.transactionID, reportID, newComment); - } + navigateBack(); + return; + } + if (iouType === CONST.IOU.TYPE.REQUEST) { + IOU.setMoneyRequestDescription(transaction.transactionID, newComment, isDraft); + if (!isDraft) { + IOU.updateMoneyRequestDescription(transaction.transactionID, reportID, newComment); } - if (iouType === CONST.IOU.TYPE.SPLIT) { - if (isDraft) { - IOU.setMoneyRequestDescription_temporaryForRefactor(transaction.transactionID, newComment, isDraft); - } else { - IOU.setDraftSplitTransaction(transaction.transactionID, {newComment}); - } + } + if (iouType === CONST.IOU.TYPE.SPLIT) { + if (isDraft) { + IOU.setMoneyRequestDescription(transaction.transactionID, newComment, isDraft); + } else { + IOU.setDraftSplitTransaction(transaction.transactionID, {newComment}); } } navigateBack(); From 37a228056a82ca9e0c239991681902b009e4fe1e Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 30 Jan 2024 18:54:01 +0700 Subject: [PATCH 11/23] clean code --- .../request/step/IOURequestStepDescription.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 51e6737173e2..3044bb0ee6be 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -76,19 +76,19 @@ function IOURequestStepDescription({ navigateBack(); return; } - if (iouType === CONST.IOU.TYPE.REQUEST) { - IOU.setMoneyRequestDescription(transaction.transactionID, newComment, isDraft); - if (!isDraft) { - IOU.updateMoneyRequestDescription(transaction.transactionID, reportID, newComment); - } + // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value + if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT) { + IOU.setDraftSplitTransaction(transaction.transactionID, {newComment}); + navigateBack(); + return; } - if (iouType === CONST.IOU.TYPE.SPLIT) { - if (isDraft) { - IOU.setMoneyRequestDescription(transaction.transactionID, newComment, isDraft); - } else { - IOU.setDraftSplitTransaction(transaction.transactionID, {newComment}); - } + + IOU.setMoneyRequestDescription(transaction.transactionID, newComment, action === CONST.IOU.ACTION.CREATE); + + if (action === CONST.IOU.ACTION.EDIT) { + IOU.updateMoneyRequestDescription(transaction.transactionID, reportID, newComment); } + navigateBack(); }; From 9cb9602c660c67df10d68898a28988c1421f073c Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 30 Jan 2024 19:01:42 +0700 Subject: [PATCH 12/23] clean code --- src/pages/iou/request/step/IOURequestStepDescription.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 3044bb0ee6be..de934f1e9fb5 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -44,7 +44,6 @@ function IOURequestStepDescription({ const {translate} = useLocalize(); const inputRef = useRef(null); const focusTimeoutRef = useRef(null); - const isDraft = action === CONST.IOU.ACTION.CREATE; useFocusEffect( useCallback(() => { focusTimeoutRef.current = setTimeout(() => { From 08ac5dce492ff3201594499194a9a0b9ff706439 Mon Sep 17 00:00:00 2001 From: DylanDylann <141406735+DylanDylann@users.noreply.github.com> Date: Tue, 30 Jan 2024 19:33:03 +0700 Subject: [PATCH 13/23] Update src/pages/iou/request/step/IOURequestStepDescription.js Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- src/pages/iou/request/step/IOURequestStepDescription.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index de934f1e9fb5..4ff95f2d5157 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -71,7 +71,7 @@ function IOURequestStepDescription({ const updateComment = (value) => { const newComment = value.moneyRequestComment.trim(); // Only update comment if it has changed - if (newComment !== lodashGet(transaction, 'comment.comment', '')) { + if (newComment === lodashGet(transaction, 'comment.comment', '')) { navigateBack(); return; } From 223373475223cc3d412d265f410fb9f45f7be483 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 30 Jan 2024 19:41:23 +0700 Subject: [PATCH 14/23] update iouType params --- src/components/MoneyRequestConfirmationList.js | 5 +---- .../iou/request/step/IOURequestStepDescription.js | 12 +++++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index cdbefc3594d0..3b95b12adad3 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -663,13 +663,10 @@ function MoneyRequestConfirmationList(props) { title={props.iouComment} description={translate('common.description')} onPress={() => { - if (!props.isEditingSplitBill) { - return; - } Navigation.navigate( ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute( CONST.IOU.ACTION.EDIT, - CONST.IOU.TYPE.SPLIT, + props.iouType, transaction.transactionID, props.reportID, Navigation.getActiveRouteWithoutParams(), diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 4ff95f2d5157..ee74e22afcd0 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -70,17 +70,19 @@ function IOURequestStepDescription({ */ const updateComment = (value) => { const newComment = value.moneyRequestComment.trim(); - // Only update comment if it has changed - if (newComment === lodashGet(transaction, 'comment.comment', '')) { - navigateBack(); - return; - } + // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT) { IOU.setDraftSplitTransaction(transaction.transactionID, {newComment}); navigateBack(); return; } + + // Only update comment if it has changed + if (newComment === lodashGet(transaction, 'comment.comment', '')) { + navigateBack(); + return; + } IOU.setMoneyRequestDescription(transaction.transactionID, newComment, action === CONST.IOU.ACTION.CREATE); From 28af0b859451961b1e4ed0fc89ca086fc2528753 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 31 Jan 2024 00:22:24 +0700 Subject: [PATCH 15/23] fix lint --- src/pages/iou/request/step/IOURequestStepDescription.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index ee74e22afcd0..41ddcc0c8feb 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -70,14 +70,14 @@ function IOURequestStepDescription({ */ const updateComment = (value) => { const newComment = value.moneyRequestComment.trim(); - + // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT) { IOU.setDraftSplitTransaction(transaction.transactionID, {newComment}); navigateBack(); return; } - + // Only update comment if it has changed if (newComment === lodashGet(transaction, 'comment.comment', '')) { navigateBack(); From 0d60886e3dc914bad11f34122fe846d840ac8cb7 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 2 Feb 2024 12:28:49 +0700 Subject: [PATCH 16/23] merge main --- src/libs/Navigation/linkingConfig.ts | 506 -------------------- src/libs/Navigation/linkingConfig/config.ts | 1 - 2 files changed, 507 deletions(-) delete mode 100644 src/libs/Navigation/linkingConfig.ts diff --git a/src/libs/Navigation/linkingConfig.ts b/src/libs/Navigation/linkingConfig.ts deleted file mode 100644 index 56d9d362ffb6..000000000000 --- a/src/libs/Navigation/linkingConfig.ts +++ /dev/null @@ -1,506 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import type {LinkingOptions} from '@react-navigation/native'; -import CONST from '@src/CONST'; -import NAVIGATORS from '@src/NAVIGATORS'; -import ROUTES from '@src/ROUTES'; -import SCREENS from '@src/SCREENS'; -import type {RootStackParamList} from './types'; - -const linkingConfig: LinkingOptions = { - prefixes: [ - 'app://-/', - 'new-expensify://', - 'https://www.expensify.cash', - 'https://staging.expensify.cash', - 'https://dev.new.expensify.com', - CONST.NEW_EXPENSIFY_URL, - CONST.STAGING_NEW_EXPENSIFY_URL, - ], - config: { - initialRouteName: SCREENS.HOME, - screens: { - // Main Routes - [SCREENS.VALIDATE_LOGIN]: ROUTES.VALIDATE_LOGIN, - [SCREENS.UNLINK_LOGIN]: ROUTES.UNLINK_LOGIN, - [SCREENS.TRANSITION_BETWEEN_APPS]: ROUTES.TRANSITION_BETWEEN_APPS, - [SCREENS.CONCIERGE]: ROUTES.CONCIERGE, - [SCREENS.SIGN_IN_WITH_APPLE_DESKTOP]: ROUTES.APPLE_SIGN_IN, - [SCREENS.SIGN_IN_WITH_GOOGLE_DESKTOP]: ROUTES.GOOGLE_SIGN_IN, - [SCREENS.SAML_SIGN_IN]: ROUTES.SAML_SIGN_IN, - [SCREENS.DESKTOP_SIGN_IN_REDIRECT]: ROUTES.DESKTOP_SIGN_IN_REDIRECT, - [SCREENS.REPORT_ATTACHMENTS]: ROUTES.REPORT_ATTACHMENTS.route, - [SCREENS.PROFILE_AVATAR]: ROUTES.PROFILE_AVATAR.route, - [SCREENS.WORKSPACE_AVATAR]: ROUTES.WORKSPACE_AVATAR.route, - [SCREENS.REPORT_AVATAR]: ROUTES.REPORT_AVATAR.route, - - // Sidebar - [SCREENS.HOME]: { - path: ROUTES.HOME, - }, - - [NAVIGATORS.CENTRAL_PANE_NAVIGATOR]: { - screens: { - [SCREENS.REPORT]: ROUTES.REPORT_WITH_ID.route, - }, - }, - [SCREENS.NOT_FOUND]: '*', - [NAVIGATORS.LEFT_MODAL_NAVIGATOR]: { - screens: { - [SCREENS.LEFT_MODAL.SEARCH]: { - screens: { - [SCREENS.SEARCH_ROOT]: ROUTES.SEARCH, - }, - }, - }, - }, - [NAVIGATORS.RIGHT_MODAL_NAVIGATOR]: { - screens: { - [SCREENS.RIGHT_MODAL.SETTINGS]: { - screens: { - [SCREENS.SETTINGS.ROOT]: { - path: ROUTES.SETTINGS, - }, - [SCREENS.SETTINGS.WORKSPACES]: { - path: ROUTES.SETTINGS_WORKSPACES, - exact: true, - }, - [SCREENS.SETTINGS.PREFERENCES.ROOT]: { - path: ROUTES.SETTINGS_PREFERENCES, - exact: true, - }, - [SCREENS.SETTINGS.PREFERENCES.PRIORITY_MODE]: { - path: ROUTES.SETTINGS_PRIORITY_MODE, - exact: true, - }, - [SCREENS.SETTINGS.PREFERENCES.LANGUAGE]: { - path: ROUTES.SETTINGS_LANGUAGE, - exact: true, - }, - [SCREENS.SETTINGS.PREFERENCES.THEME]: { - path: ROUTES.SETTINGS_THEME, - exact: true, - }, - [SCREENS.SETTINGS.CLOSE]: { - path: ROUTES.SETTINGS_CLOSE, - exact: true, - }, - [SCREENS.SETTINGS.SECURITY]: { - path: ROUTES.SETTINGS_SECURITY, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.ROOT]: { - path: ROUTES.SETTINGS_WALLET, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.DOMAIN_CARD]: { - path: ROUTES.SETTINGS_WALLET_DOMAINCARD.route, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.REPORT_VIRTUAL_CARD_FRAUD]: { - path: ROUTES.SETTINGS_REPORT_FRAUD.route, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.CARD_GET_PHYSICAL.NAME]: { - path: ROUTES.SETTINGS_WALLET_CARD_GET_PHYSICAL_NAME.route, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.CARD_GET_PHYSICAL.PHONE]: { - path: ROUTES.SETTINGS_WALLET_CARD_GET_PHYSICAL_PHONE.route, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.CARD_GET_PHYSICAL.ADDRESS]: { - path: ROUTES.SETTINGS_WALLET_CARD_GET_PHYSICAL_ADDRESS.route, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.CARD_GET_PHYSICAL.CONFIRM]: { - path: ROUTES.SETTINGS_WALLET_CARD_GET_PHYSICAL_CONFIRM.route, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.ENABLE_PAYMENTS]: { - path: ROUTES.SETTINGS_ENABLE_PAYMENTS, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.TRANSFER_BALANCE]: { - path: ROUTES.SETTINGS_WALLET_TRANSFER_BALANCE, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.CHOOSE_TRANSFER_ACCOUNT]: { - path: ROUTES.SETTINGS_WALLET_CHOOSE_TRANSFER_ACCOUNT, - exact: true, - }, - [SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED]: { - path: ROUTES.SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED.route, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.CARD_ACTIVATE]: { - path: ROUTES.SETTINGS_WALLET_CARD_ACTIVATE.route, - exact: true, - }, - [SCREENS.SETTINGS.WALLET.CARDS_DIGITAL_DETAILS_UPDATE_ADDRESS]: { - path: ROUTES.SETTINGS_WALLET_CARD_DIGITAL_DETAILS_UPDATE_ADDRESS.route, - exact: true, - }, - [SCREENS.SETTINGS.ADD_DEBIT_CARD]: { - path: ROUTES.SETTINGS_ADD_DEBIT_CARD, - exact: true, - }, - [SCREENS.SETTINGS.ADD_BANK_ACCOUNT]: { - path: ROUTES.SETTINGS_ADD_BANK_ACCOUNT, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.ROOT]: { - path: ROUTES.SETTINGS_PROFILE, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.PRONOUNS]: { - path: ROUTES.SETTINGS_PRONOUNS, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.DISPLAY_NAME]: { - path: ROUTES.SETTINGS_DISPLAY_NAME, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.TIMEZONE]: { - path: ROUTES.SETTINGS_TIMEZONE, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.TIMEZONE_SELECT]: { - path: ROUTES.SETTINGS_TIMEZONE_SELECT, - exact: true, - }, - [SCREENS.SETTINGS.ABOUT]: { - path: ROUTES.SETTINGS_ABOUT, - exact: true, - }, - [SCREENS.SETTINGS.APP_DOWNLOAD_LINKS]: { - path: ROUTES.SETTINGS_APP_DOWNLOAD_LINKS, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.CONTACT_METHODS]: { - path: ROUTES.SETTINGS_CONTACT_METHODS.route, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.CONTACT_METHOD_DETAILS]: { - path: ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.route, - }, - [SCREENS.SETTINGS.LOUNGE_ACCESS]: { - path: ROUTES.SETTINGS_LOUNGE_ACCESS, - }, - [SCREENS.SETTINGS.PROFILE.NEW_CONTACT_METHOD]: { - path: ROUTES.SETTINGS_NEW_CONTACT_METHOD.route, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.PERSONAL_DETAILS.INITIAL]: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.PERSONAL_DETAILS.LEGAL_NAME]: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS_LEGAL_NAME, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.PERSONAL_DETAILS.DATE_OF_BIRTH]: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS_DATE_OF_BIRTH, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.PERSONAL_DETAILS.ADDRESS]: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.PERSONAL_DETAILS.ADDRESS_COUNTRY]: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS_COUNTRY.route, - exact: true, - }, - [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: { - path: ROUTES.SETTINGS_2FA.route, - exact: true, - }, - [SCREENS.SETTINGS.SHARE_CODE]: { - path: ROUTES.SETTINGS_SHARE_CODE, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.STATUS]: { - path: ROUTES.SETTINGS_STATUS, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE.STATUS_CLEAR_AFTER]: { - path: ROUTES.SETTINGS_STATUS_CLEAR_AFTER, - }, - [SCREENS.SETTINGS.PROFILE.STATUS_CLEAR_AFTER_DATE]: { - path: ROUTES.SETTINGS_STATUS_CLEAR_AFTER_DATE, - }, - [SCREENS.SETTINGS.PROFILE.STATUS_CLEAR_AFTER_TIME]: { - path: ROUTES.SETTINGS_STATUS_CLEAR_AFTER_TIME, - }, - [SCREENS.WORKSPACE.INITIAL]: { - path: ROUTES.WORKSPACE_INITIAL.route, - }, - [SCREENS.WORKSPACE.SETTINGS]: { - path: ROUTES.WORKSPACE_SETTINGS.route, - }, - [SCREENS.WORKSPACE.CURRENCY]: { - path: ROUTES.WORKSPACE_SETTINGS_CURRENCY.route, - }, - [SCREENS.WORKSPACE.CARD]: { - path: ROUTES.WORKSPACE_CARD.route, - }, - [SCREENS.WORKSPACE.REIMBURSE]: { - path: ROUTES.WORKSPACE_REIMBURSE.route, - }, - [SCREENS.WORKSPACE.RATE_AND_UNIT]: { - path: ROUTES.WORKSPACE_RATE_AND_UNIT.route, - }, - [SCREENS.WORKSPACE.BILLS]: { - path: ROUTES.WORKSPACE_BILLS.route, - }, - [SCREENS.WORKSPACE.INVOICES]: { - path: ROUTES.WORKSPACE_INVOICES.route, - }, - [SCREENS.WORKSPACE.TRAVEL]: { - path: ROUTES.WORKSPACE_TRAVEL.route, - }, - [SCREENS.WORKSPACE.MEMBERS]: { - path: ROUTES.WORKSPACE_MEMBERS.route, - }, - [SCREENS.WORKSPACE.INVITE]: { - path: ROUTES.WORKSPACE_INVITE.route, - }, - [SCREENS.WORKSPACE.INVITE_MESSAGE]: { - path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, - }, - [SCREENS.REIMBURSEMENT_ACCOUNT]: { - path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.route, - exact: true, - }, - [SCREENS.GET_ASSISTANCE]: { - path: ROUTES.GET_ASSISTANCE.route, - }, - [SCREENS.KEYBOARD_SHORTCUTS]: { - path: ROUTES.KEYBOARD_SHORTCUTS, - }, - }, - }, - [SCREENS.RIGHT_MODAL.PRIVATE_NOTES]: { - screens: { - [SCREENS.PRIVATE_NOTES.LIST]: ROUTES.PRIVATE_NOTES_LIST.route, - [SCREENS.PRIVATE_NOTES.EDIT]: ROUTES.PRIVATE_NOTES_EDIT.route, - }, - }, - [SCREENS.RIGHT_MODAL.REPORT_DETAILS]: { - screens: { - [SCREENS.REPORT_DETAILS.ROOT]: ROUTES.REPORT_WITH_ID_DETAILS.route, - [SCREENS.REPORT_DETAILS.SHARE_CODE]: ROUTES.REPORT_WITH_ID_DETAILS_SHARE_CODE.route, - }, - }, - [SCREENS.RIGHT_MODAL.REPORT_SETTINGS]: { - screens: { - [SCREENS.REPORT_SETTINGS.ROOT]: { - path: ROUTES.REPORT_SETTINGS.route, - }, - [SCREENS.REPORT_SETTINGS.ROOM_NAME]: { - path: ROUTES.REPORT_SETTINGS_ROOM_NAME.route, - }, - [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: { - path: ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.route, - }, - [SCREENS.REPORT_SETTINGS.WRITE_CAPABILITY]: { - path: ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.route, - }, - }, - }, - [SCREENS.RIGHT_MODAL.REPORT_WELCOME_MESSAGE]: { - screens: { - [SCREENS.REPORT_WELCOME_MESSAGE_ROOT]: ROUTES.REPORT_WELCOME_MESSAGE.route, - }, - }, - [SCREENS.RIGHT_MODAL.NEW_CHAT]: { - screens: { - [SCREENS.NEW_CHAT.ROOT]: { - path: ROUTES.NEW, - exact: true, - screens: { - [SCREENS.NEW_CHAT.NEW_CHAT]: { - path: ROUTES.NEW_CHAT, - exact: true, - }, - [SCREENS.NEW_CHAT.NEW_ROOM]: { - path: ROUTES.NEW_ROOM, - exact: true, - }, - }, - }, - }, - }, - [SCREENS.RIGHT_MODAL.NEW_TASK]: { - screens: { - [SCREENS.NEW_TASK.ROOT]: ROUTES.NEW_TASK, - [SCREENS.NEW_TASK.TASK_ASSIGNEE_SELECTOR]: ROUTES.NEW_TASK_ASSIGNEE, - [SCREENS.NEW_TASK.TASK_SHARE_DESTINATION_SELECTOR]: ROUTES.NEW_TASK_SHARE_DESTINATION, - [SCREENS.NEW_TASK.DETAILS]: ROUTES.NEW_TASK_DETAILS, - [SCREENS.NEW_TASK.TITLE]: ROUTES.NEW_TASK_TITLE, - [SCREENS.NEW_TASK.DESCRIPTION]: ROUTES.NEW_TASK_DESCRIPTION, - }, - }, - [SCREENS.RIGHT_MODAL.TEACHERS_UNITE]: { - screens: { - [SCREENS.SAVE_THE_WORLD.ROOT]: ROUTES.TEACHERS_UNITE, - [SCREENS.I_KNOW_A_TEACHER]: ROUTES.I_KNOW_A_TEACHER, - [SCREENS.INTRO_SCHOOL_PRINCIPAL]: ROUTES.INTRO_SCHOOL_PRINCIPAL, - [SCREENS.I_AM_A_TEACHER]: ROUTES.I_AM_A_TEACHER, - }, - }, - [SCREENS.RIGHT_MODAL.DETAILS]: { - screens: { - [SCREENS.DETAILS_ROOT]: ROUTES.DETAILS.route, - }, - }, - [SCREENS.RIGHT_MODAL.PROFILE]: { - screens: { - [SCREENS.PROFILE_ROOT]: ROUTES.PROFILE.route, - }, - }, - [SCREENS.RIGHT_MODAL.PARTICIPANTS]: { - screens: { - [SCREENS.REPORT_PARTICIPANTS_ROOT]: ROUTES.REPORT_PARTICIPANTS.route, - }, - }, - [SCREENS.RIGHT_MODAL.ROOM_INVITE]: { - screens: { - [SCREENS.ROOM_INVITE_ROOT]: ROUTES.ROOM_INVITE.route, - }, - }, - [SCREENS.RIGHT_MODAL.ROOM_MEMBERS]: { - screens: { - [SCREENS.ROOM_MEMBERS_ROOT]: ROUTES.ROOM_MEMBERS.route, - }, - }, - [SCREENS.RIGHT_MODAL.MONEY_REQUEST]: { - screens: { - [SCREENS.MONEY_REQUEST.START]: ROUTES.MONEY_REQUEST_START.route, - [SCREENS.MONEY_REQUEST.CREATE]: { - path: ROUTES.MONEY_REQUEST_CREATE.route, - exact: true, - screens: { - distance: { - path: ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.route, - exact: true, - }, - manual: { - path: ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.route, - exact: true, - }, - scan: { - path: ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.route, - exact: true, - }, - }, - }, - [SCREENS.MONEY_REQUEST.STEP_AMOUNT]: ROUTES.MONEY_REQUEST_STEP_AMOUNT.route, - [SCREENS.MONEY_REQUEST.STEP_CATEGORY]: ROUTES.MONEY_REQUEST_STEP_CATEGORY.route, - [SCREENS.MONEY_REQUEST.STEP_CONFIRMATION]: ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.route, - [SCREENS.MONEY_REQUEST.STEP_CURRENCY]: ROUTES.MONEY_REQUEST_STEP_CURRENCY.route, - [SCREENS.MONEY_REQUEST.STEP_DATE]: ROUTES.MONEY_REQUEST_STEP_DATE.route, - [SCREENS.MONEY_REQUEST.STEP_DESCRIPTION]: ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.route, - [SCREENS.MONEY_REQUEST.STEP_DISTANCE]: ROUTES.MONEY_REQUEST_STEP_DISTANCE.route, - [SCREENS.MONEY_REQUEST.STEP_MERCHANT]: ROUTES.MONEY_REQUEST_STEP_MERCHANT.route, - [SCREENS.MONEY_REQUEST.STEP_PARTICIPANTS]: ROUTES.MONEY_REQUEST_STEP_PARTICIPANTS.route, - [SCREENS.MONEY_REQUEST.STEP_SCAN]: ROUTES.MONEY_REQUEST_STEP_SCAN.route, - [SCREENS.MONEY_REQUEST.STEP_TAG]: ROUTES.MONEY_REQUEST_STEP_TAG.route, - [SCREENS.MONEY_REQUEST.STEP_WAYPOINT]: ROUTES.MONEY_REQUEST_STEP_WAYPOINT.route, - [SCREENS.MONEY_REQUEST.ROOT]: { - path: ROUTES.MONEY_REQUEST.route, - exact: true, - screens: { - [SCREENS.MONEY_REQUEST.MANUAL_TAB]: { - path: ROUTES.MONEY_REQUEST_MANUAL_TAB, - exact: true, - }, - [SCREENS.MONEY_REQUEST.SCAN_TAB]: { - path: ROUTES.MONEY_REQUEST_SCAN_TAB, - exact: true, - }, - [SCREENS.MONEY_REQUEST.DISTANCE_TAB]: { - path: ROUTES.MONEY_REQUEST_DISTANCE_TAB.route, - exact: true, - }, - }, - }, - [SCREENS.MONEY_REQUEST.AMOUNT]: ROUTES.MONEY_REQUEST_AMOUNT.route, - [SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.route, - [SCREENS.MONEY_REQUEST.STEP_TAX_RATE]: ROUTES.MONEY_REQUEST_STEP_TAX_RATE.route, - [SCREENS.MONEY_REQUEST.PARTICIPANTS]: ROUTES.MONEY_REQUEST_PARTICIPANTS.route, - [SCREENS.MONEY_REQUEST.CONFIRMATION]: ROUTES.MONEY_REQUEST_CONFIRMATION.route, - [SCREENS.MONEY_REQUEST.DATE]: ROUTES.MONEY_REQUEST_DATE.route, - [SCREENS.MONEY_REQUEST.CURRENCY]: ROUTES.MONEY_REQUEST_CURRENCY.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, - [SCREENS.MONEY_REQUEST.DISTANCE]: ROUTES.MONEY_REQUEST_DISTANCE.route, - [SCREENS.IOU_SEND.ENABLE_PAYMENTS]: ROUTES.IOU_SEND_ENABLE_PAYMENTS, - [SCREENS.IOU_SEND.ADD_BANK_ACCOUNT]: ROUTES.IOU_SEND_ADD_BANK_ACCOUNT, - [SCREENS.IOU_SEND.ADD_DEBIT_CARD]: ROUTES.IOU_SEND_ADD_DEBIT_CARD, - }, - }, - [SCREENS.RIGHT_MODAL.SPLIT_DETAILS]: { - screens: { - [SCREENS.SPLIT_DETAILS.ROOT]: ROUTES.SPLIT_BILL_DETAILS.route, - [SCREENS.SPLIT_DETAILS.EDIT_REQUEST]: ROUTES.EDIT_SPLIT_BILL.route, - [SCREENS.SPLIT_DETAILS.EDIT_CURRENCY]: ROUTES.EDIT_SPLIT_BILL_CURRENCY.route, - }, - }, - [SCREENS.RIGHT_MODAL.TASK_DETAILS]: { - screens: { - [SCREENS.TASK.TITLE]: ROUTES.TASK_TITLE.route, - [SCREENS.TASK.DESCRIPTION]: ROUTES.TASK_DESCRIPTION.route, - [SCREENS.TASK.ASSIGNEE]: ROUTES.TASK_ASSIGNEE.route, - }, - }, - [SCREENS.RIGHT_MODAL.ADD_PERSONAL_BANK_ACCOUNT]: { - screens: { - [SCREENS.ADD_PERSONAL_BANK_ACCOUNT_ROOT]: ROUTES.BANK_ACCOUNT_PERSONAL, - }, - }, - [SCREENS.RIGHT_MODAL.ENABLE_PAYMENTS]: { - screens: { - [SCREENS.ENABLE_PAYMENTS_ROOT]: ROUTES.ENABLE_PAYMENTS, - }, - }, - [SCREENS.RIGHT_MODAL.WALLET_STATEMENT]: { - screens: { - [SCREENS.WALLET_STATEMENT_ROOT]: ROUTES.WALLET_STATEMENT_WITH_DATE, - }, - }, - [SCREENS.RIGHT_MODAL.FLAG_COMMENT]: { - screens: { - [SCREENS.FLAG_COMMENT_ROOT]: ROUTES.FLAG_COMMENT.route, - }, - }, - [SCREENS.RIGHT_MODAL.EDIT_REQUEST]: { - screens: { - [SCREENS.EDIT_REQUEST.ROOT]: ROUTES.EDIT_REQUEST.route, - [SCREENS.EDIT_REQUEST.CURRENCY]: ROUTES.EDIT_CURRENCY_REQUEST.route, - [SCREENS.EDIT_REQUEST.REPORT_FIELD]: ROUTES.EDIT_REPORT_FIELD_REQUEST.route, - }, - }, - [SCREENS.RIGHT_MODAL.SIGN_IN]: { - screens: { - [SCREENS.SIGN_IN_ROOT]: ROUTES.SIGN_IN_MODAL, - }, - }, - [SCREENS.RIGHT_MODAL.REFERRAL]: { - screens: { - [SCREENS.REFERRAL_DETAILS]: ROUTES.REFERRAL_DETAILS_MODAL.route, - }, - }, - ProcessMoneyRequestHold: { - screens: { - ProcessMoneyRequestHold_Root: ROUTES.PROCESS_MONEY_REQUEST_HOLD, - }, - }, - }, - }, - }, - }, -}; - -export default linkingConfig; diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index f1c9c316fe93..304215c0e49b 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -404,7 +404,6 @@ const config: LinkingOptions['config'] = { [SCREENS.MONEY_REQUEST.CONFIRMATION]: ROUTES.MONEY_REQUEST_CONFIRMATION.route, [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, From e3f6ecf7e9560656e774732dcc1c0904e2d5e4a1 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 2 Feb 2024 16:50:17 +0700 Subject: [PATCH 17/23] update param --- src/pages/iou/request/step/IOURequestStepDescription.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 41ddcc0c8feb..2b753931aa4a 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -73,7 +73,7 @@ function IOURequestStepDescription({ // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT) { - IOU.setDraftSplitTransaction(transaction.transactionID, {newComment}); + IOU.setDraftSplitTransaction(transaction.transactionID, {comment: newComment}); navigateBack(); return; } From 7d8e0d5f3fedcc8b6e5e2bb106231c91d50d69c3 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 5 Feb 2024 22:51:22 +0700 Subject: [PATCH 18/23] fix types --- src/libs/Navigation/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 9c6cd8ed6981..cde54e2559e2 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -216,8 +216,8 @@ type MoneyRequestNavigatorParamList = { threadReportID: string; }; [SCREENS.MONEY_REQUEST.STEP_DESCRIPTION]: { - action: string; - iouType: string; + action: ValueOf; + iouType: ValueOf; reportID: string; field: string; threadReportID: string; From e86aaa7f828e2c7424809878c3b5075321d5ed10 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 5 Feb 2024 22:57:07 +0700 Subject: [PATCH 19/23] fix types --- 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 285d4c6f860f..3cf009313c90 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -273,7 +273,7 @@ function MoneyRequestView({ ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute( CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, - transaction.transactionID, + transaction?.transactionID ?? '', report.reportID, Navigation.getActiveRouteWithoutParams(), ), From 446a515fdea9421821e2070a454e9a35c94245e1 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 5 Feb 2024 23:20:41 +0700 Subject: [PATCH 20/23] add draft trsanaction to get default value --- .../request/step/IOURequestStepDescription.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 2b753931aa4a..9c16f6076201 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -2,6 +2,7 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; import React, {useCallback, useRef} from 'react'; import {View} from 'react-native'; +import {withOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; import InputWrapperWithRef from '@components/Form/InputWrapper'; import TextInput from '@components/TextInput'; @@ -28,10 +29,14 @@ const propTypes = { /** Onyx Props */ /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ transaction: transactionPropTypes, + + /** The draft transaction that holds data to be persisted on the current transaction */ + draftTransaction: transactionPropTypes, }; const defaultProps = { transaction: {}, + draftTransaction: undefined, }; function IOURequestStepDescription({ @@ -39,6 +44,7 @@ function IOURequestStepDescription({ params: {action, iouType, reportID, backTo}, }, transaction, + draftTransaction, }) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -60,6 +66,8 @@ function IOURequestStepDescription({ }, []), ); + const currentDescription = lodashGet(draftTransaction, 'comment.comment', undefined) || lodashGet(transaction, 'comment.comment', ''); + const navigateBack = () => { Navigation.goBack(backTo || ROUTES.HOME); }; @@ -79,7 +87,7 @@ function IOURequestStepDescription({ } // Only update comment if it has changed - if (newComment === lodashGet(transaction, 'comment.comment', '')) { + if (newComment === currentDescription) { navigateBack(); return; } @@ -112,7 +120,7 @@ function IOURequestStepDescription({ InputComponent={TextInput} inputID="moneyRequestComment" name="moneyRequestComment" - defaultValue={lodashGet(transaction, 'comment.comment', '')} + defaultValue={currentDescription} label={translate('moneyRequestConfirmationList.whatsItFor')} accessibilityLabel={translate('moneyRequestConfirmationList.whatsItFor')} role={CONST.ROLE.PRESENTATION} @@ -137,4 +145,12 @@ IOURequestStepDescription.propTypes = propTypes; IOURequestStepDescription.defaultProps = defaultProps; IOURequestStepDescription.displayName = 'IOURequestStepDescription'; -export default compose(withWritableReportOrNotFound, withFullTransactionOrNotFound)(IOURequestStepDescription); +export default compose( + withWritableReportOrNotFound, + withFullTransactionOrNotFound, + withOnyx({ + draftTransaction: { + key: ({transaction}) => `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transaction.transactionID}`, + }, + }), +)(IOURequestStepDescription); From 3e557ac289d0a6c6e973b5454a785619f667d32d Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 6 Feb 2024 18:08:24 +0700 Subject: [PATCH 21/23] fix types --- src/libs/Navigation/types.ts | 4 +-- .../request/step/IOURequestStepDescription.js | 27 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 676dcafb7d05..b65f7553a3d6 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -218,9 +218,9 @@ type MoneyRequestNavigatorParamList = { [SCREENS.MONEY_REQUEST.STEP_DESCRIPTION]: { action: ValueOf; iouType: ValueOf; + transactionID: string; reportID: string; - field: string; - threadReportID: string; + backTo: string; }; [SCREENS.MONEY_REQUEST.CATEGORY]: { iouType: string; diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 9c16f6076201..3f42af8d0976 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -1,5 +1,6 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; +import lodashIsEmpty from 'lodash/isEmpty'; import React, {useCallback, useRef} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; @@ -31,12 +32,12 @@ const propTypes = { transaction: transactionPropTypes, /** The draft transaction that holds data to be persisted on the current transaction */ - draftTransaction: transactionPropTypes, + splitDraftTransaction: transactionPropTypes, }; const defaultProps = { transaction: {}, - draftTransaction: undefined, + splitDraftTransaction: {}, }; function IOURequestStepDescription({ @@ -44,7 +45,7 @@ function IOURequestStepDescription({ params: {action, iouType, reportID, backTo}, }, transaction, - draftTransaction, + splitDraftTransaction, }) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -66,7 +67,11 @@ function IOURequestStepDescription({ }, []), ); - const currentDescription = lodashGet(draftTransaction, 'comment.comment', undefined) || lodashGet(transaction, 'comment.comment', ''); + let currentDescription = lodashGet(transaction, 'comment.comment', ''); + + if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT && !lodashIsEmpty(splitDraftTransaction)) { + currentDescription = lodashGet(splitDraftTransaction, 'comment.comment', '') + } const navigateBack = () => { Navigation.goBack(backTo || ROUTES.HOME); @@ -79,15 +84,15 @@ function IOURequestStepDescription({ const updateComment = (value) => { const newComment = value.moneyRequestComment.trim(); - // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value - if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT) { - IOU.setDraftSplitTransaction(transaction.transactionID, {comment: newComment}); + // Only update comment if it has changed + if (newComment === currentDescription) { navigateBack(); return; } - // Only update comment if it has changed - if (newComment === currentDescription) { + // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value + if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT) { + IOU.setDraftSplitTransaction(transaction.transactionID, {comment: newComment}); navigateBack(); return; } @@ -149,8 +154,8 @@ export default compose( withWritableReportOrNotFound, withFullTransactionOrNotFound, withOnyx({ - draftTransaction: { - key: ({transaction}) => `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transaction.transactionID}`, + splitDraftTransaction: { + key: ({route}) => `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${route.transactionID}`, }, }), )(IOURequestStepDescription); From 387113ad9ac671c6625b6f5aa17b4c92f20a9f71 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 6 Feb 2024 21:02:19 +0700 Subject: [PATCH 22/23] fix lint --- src/libs/actions/IOU.ts | 1 - .../iou/request/step/IOURequestStepDescription.js | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 9a6bb63aae25..c7e2d6b09dc0 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -286,7 +286,6 @@ function setMoneyRequestOriginalCurrency_temporaryForRefactor(transactionID: str Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {originalCurrency}); } - function setMoneyRequestDescription(transactionID: string, comment: string, isDraft: boolean) { Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {comment: {comment: comment.trim()}}); } diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 3f42af8d0976..367c79fed6a1 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -51,6 +51,10 @@ function IOURequestStepDescription({ const {translate} = useLocalize(); const inputRef = useRef(null); const focusTimeoutRef = useRef(null); + // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value + const isEditingSplitBill = iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT; + const currentDescription = + isEditingSplitBill && !lodashIsEmpty(splitDraftTransaction) ? lodashGet(splitDraftTransaction, 'comment.comment', '') : lodashGet(transaction, 'comment.comment', ''); useFocusEffect( useCallback(() => { focusTimeoutRef.current = setTimeout(() => { @@ -67,12 +71,6 @@ function IOURequestStepDescription({ }, []), ); - let currentDescription = lodashGet(transaction, 'comment.comment', ''); - - if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT && !lodashIsEmpty(splitDraftTransaction)) { - currentDescription = lodashGet(splitDraftTransaction, 'comment.comment', '') - } - const navigateBack = () => { Navigation.goBack(backTo || ROUTES.HOME); }; @@ -155,7 +153,10 @@ export default compose( withFullTransactionOrNotFound, withOnyx({ splitDraftTransaction: { - key: ({route}) => `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${route.transactionID}`, + key: ({route}) => { + const transactionID = lodashGet(route, 'params.transactionID', 0); + return `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`; + }, }, }), )(IOURequestStepDescription); From c40f1d3ecff432c5eb852c841e99714d31939833 Mon Sep 17 00:00:00 2001 From: DylanDylann <141406735+DylanDylann@users.noreply.github.com> Date: Tue, 6 Feb 2024 21:36:44 +0700 Subject: [PATCH 23/23] Update src/pages/iou/request/step/IOURequestStepDescription.js Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- src/pages/iou/request/step/IOURequestStepDescription.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDescription.js b/src/pages/iou/request/step/IOURequestStepDescription.js index 367c79fed6a1..25477170f505 100644 --- a/src/pages/iou/request/step/IOURequestStepDescription.js +++ b/src/pages/iou/request/step/IOURequestStepDescription.js @@ -89,7 +89,7 @@ function IOURequestStepDescription({ } // In the split flow, when editing we use SPLIT_TRANSACTION_DRAFT to save draft value - if (iouType === CONST.IOU.TYPE.SPLIT && action === CONST.IOU.ACTION.EDIT) { + if (isEditingSplitBill) { IOU.setDraftSplitTransaction(transaction.transactionID, {comment: newComment}); navigateBack(); return;