From ae942cf4ef3eeebee9363e1a7fb1cccc9cd9aa3a Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Thu, 19 Oct 2023 10:58:11 +0700 Subject: [PATCH 01/10] Update request money header title --- src/pages/iou/steps/MoneyRequestConfirmPage.js | 4 ++++ .../MoneyRequestParticipantsPage.js | 16 +++++++++++++--- .../MoneyRequestParticipantsSelector.js | 8 +++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 46367e275af4..616955e1cd80 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -308,6 +308,10 @@ function MoneyRequestConfirmPage(props) { return props.translate('common.send'); } + if (isScanRequest) { + return props.translate('tabSelector.scan'); + } + return props.translate('tabSelector.manual'); }; diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index 25e41ba78556..fb3799336cc8 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -54,6 +54,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { const isScanRequest = MoneyRequestUtils.isScanRequest(selectedTab); const isSplitRequest = iou.id === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT; const [headerTitle, setHeaderTitle] = useState(); + const [selectedParticipants, setSelectedParticipants] = useState([]); useEffect(() => { if (isDistanceRequest) { @@ -66,10 +67,18 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { return; } - setHeaderTitle(_.isEmpty(iou.participants) ? translate('tabSelector.manual') : translate('iou.split')); - }, [iou.participants, isDistanceRequest, isSendRequest, translate]); + if (isScanRequest) { + setHeaderTitle(translate('tabSelector.scan')); + return; + } + + setHeaderTitle(_.isEmpty(selectedParticipants) ? translate('tabSelector.manual') : translate('iou.split')); + }, [selectedParticipants, isDistanceRequest, translate, isScanRequest]); const navigateToConfirmationStep = (moneyRequestType) => { + if (moneyRequestType === iouType.current) { + setSelectedParticipants([]); + } IOU.setMoneyRequestId(moneyRequestType); Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(moneyRequestType, reportID.current)); }; @@ -118,7 +127,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { /> (optionsSelectorRef.current = el)} - participants={iou.participants} + participants={selectedParticipants} onAddParticipants={IOU.setMoneyRequestParticipants} navigateToRequest={() => navigateToConfirmationStep(iouType.current)} navigateToSplit={() => navigateToConfirmationStep(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT)} @@ -126,6 +135,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { iouType={iouType.current} isDistanceRequest={isDistanceRequest} isScanRequest={isScanRequest} + setSelectedParticipants={setSelectedParticipants} /> )} diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 547d2b7c363a..5a3a5a797946 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -47,6 +47,9 @@ const propTypes = { /** All of the personal details for everyone */ personalDetails: PropTypes.objectOf(personalDetailsPropType), + /** Callback to request parent modal to go to next step, which should be split */ + setSelectedParticipants: PropTypes.func.isRequired, + /** All reports shared with the user */ reports: PropTypes.objectOf(reportPropTypes), @@ -85,6 +88,7 @@ function MoneyRequestParticipantsSelector({ safeAreaPaddingBottomStyle, iouType, isDistanceRequest, + setSelectedParticipants, }) { const [searchTerm, setSearchTerm] = useState(''); const [newChatOptions, setNewChatOptions] = useState({ @@ -198,9 +202,11 @@ function MoneyRequestParticipantsSelector({ ]; } + setSelectedParticipants(newSelectedOptions); + onAddParticipants(newSelectedOptions); }, - [participants, onAddParticipants], + [participants, onAddParticipants, setSelectedParticipants], ); const headerMessage = OptionsListUtils.getHeaderMessage( From c34e28403dc574b6b5f5a6fffae3c6b5755ae1ba Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Thu, 19 Oct 2023 11:24:55 +0700 Subject: [PATCH 02/10] fix lint --- .../MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index fb3799336cc8..9e2f1a3a1f45 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -73,7 +73,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { } setHeaderTitle(_.isEmpty(selectedParticipants) ? translate('tabSelector.manual') : translate('iou.split')); - }, [selectedParticipants, isDistanceRequest, translate, isScanRequest]); + }, [selectedParticipants, isDistanceRequest, translate, isScanRequest, isSendRequest]); const navigateToConfirmationStep = (moneyRequestType) => { if (moneyRequestType === iouType.current) { From 52919facbe7c256270c250be89f0933f00d55d3d Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Mon, 23 Oct 2023 21:25:31 +0700 Subject: [PATCH 03/10] Add default value to selected participants --- .../MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index 9e2f1a3a1f45..768f66cc2c7f 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -54,7 +54,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { const isScanRequest = MoneyRequestUtils.isScanRequest(selectedTab); const isSplitRequest = iou.id === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT; const [headerTitle, setHeaderTitle] = useState(); - const [selectedParticipants, setSelectedParticipants] = useState([]); + const [selectedParticipants, setSelectedParticipants] = useState(iou.participants); useEffect(() => { if (isDistanceRequest) { From 6514698aacab9ed95f6ba7998308f272decd8a8b Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 25 Oct 2023 23:31:26 +0700 Subject: [PATCH 04/10] Add isSplitRequest to IOU onyx --- src/libs/actions/IOU.js | 8 ++++++++ .../MoneyRequestParticipantsPage.js | 12 +++--------- .../MoneyRequestParticipantsSelector.js | 15 ++++++++------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 422dd8fbb03a..80a2fed6fe67 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -2834,6 +2834,13 @@ function setMoneyRequestParticipants(participants) { Onyx.merge(ONYXKEYS.IOU, {participants}); } +/** + * @param {Boolean} isSplitRequest + */ +function setMoneyRequestIsSplitRequest(isSplitRequest) { + Onyx.merge(ONYXKEYS.IOU, {isSplitRequest}); +} + /** * @param {String} receiptPath * @param {String} receiptFilename @@ -2941,6 +2948,7 @@ export { resetMoneyRequestTag, setMoneyRequestBillable, setMoneyRequestParticipants, + setMoneyRequestIsSplitRequest, setMoneyRequestReceipt, setUpDistanceTransaction, navigateToNextPage, diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index 768f66cc2c7f..d83b562b0ba0 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -3,7 +3,6 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; -import _ from 'underscore'; import CONST from '../../../../CONST'; import ONYXKEYS from '../../../../ONYXKEYS'; import ROUTES from '../../../../ROUTES'; @@ -54,7 +53,6 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { const isScanRequest = MoneyRequestUtils.isScanRequest(selectedTab); const isSplitRequest = iou.id === CONST.IOU.MONEY_REQUEST_TYPE.SPLIT; const [headerTitle, setHeaderTitle] = useState(); - const [selectedParticipants, setSelectedParticipants] = useState(iou.participants); useEffect(() => { if (isDistanceRequest) { @@ -72,13 +70,10 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { return; } - setHeaderTitle(_.isEmpty(selectedParticipants) ? translate('tabSelector.manual') : translate('iou.split')); - }, [selectedParticipants, isDistanceRequest, translate, isScanRequest, isSendRequest]); + setHeaderTitle(iou.isSplitRequest ? translate('iou.split') : translate('tabSelector.manual')); + }, [iou.isSplitRequest, isDistanceRequest, translate, isScanRequest, isSendRequest]); const navigateToConfirmationStep = (moneyRequestType) => { - if (moneyRequestType === iouType.current) { - setSelectedParticipants([]); - } IOU.setMoneyRequestId(moneyRequestType); Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(moneyRequestType, reportID.current)); }; @@ -127,7 +122,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { /> (optionsSelectorRef.current = el)} - participants={selectedParticipants} + participants={iou.participants} onAddParticipants={IOU.setMoneyRequestParticipants} navigateToRequest={() => navigateToConfirmationStep(iouType.current)} navigateToSplit={() => navigateToConfirmationStep(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT)} @@ -135,7 +130,6 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { iouType={iouType.current} isDistanceRequest={isDistanceRequest} isScanRequest={isScanRequest} - setSelectedParticipants={setSelectedParticipants} /> )} diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 5a3a5a797946..a98de08f7e4d 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -16,6 +16,7 @@ import CONST from '../../../../CONST'; import personalDetailsPropType from '../../../personalDetailsPropType'; import reportPropTypes from '../../../reportPropTypes'; import refPropTypes from '../../../../components/refPropTypes'; +import * as IOU from '../../../../libs/actions/IOU'; const propTypes = { /** Beta features list */ @@ -47,9 +48,6 @@ const propTypes = { /** All of the personal details for everyone */ personalDetails: PropTypes.objectOf(personalDetailsPropType), - /** Callback to request parent modal to go to next step, which should be split */ - setSelectedParticipants: PropTypes.func.isRequired, - /** All reports shared with the user */ reports: PropTypes.objectOf(reportPropTypes), @@ -88,7 +86,6 @@ function MoneyRequestParticipantsSelector({ safeAreaPaddingBottomStyle, iouType, isDistanceRequest, - setSelectedParticipants, }) { const [searchTerm, setSearchTerm] = useState(''); const [newChatOptions, setNewChatOptions] = useState({ @@ -163,6 +160,7 @@ function MoneyRequestParticipantsSelector({ onAddParticipants([ {accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true, searchText: option.searchText}, ]); + IOU.setMoneyRequestIsSplitRequest(false); navigateToRequest(); }; @@ -202,11 +200,14 @@ function MoneyRequestParticipantsSelector({ ]; } - setSelectedParticipants(newSelectedOptions); - + if (newSelectedOptions.length === 0) { + IOU.setMoneyRequestIsSplitRequest(false); + } else { + IOU.setMoneyRequestIsSplitRequest(true); + } onAddParticipants(newSelectedOptions); }, - [participants, onAddParticipants, setSelectedParticipants], + [participants, onAddParticipants], ); const headerMessage = OptionsListUtils.getHeaderMessage( From 8ee843ad1f5cbf7a245f403350518b9f1d8080af Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 25 Oct 2023 23:47:37 +0700 Subject: [PATCH 05/10] fix lint --- .../MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index d83b562b0ba0..cefbd1d0c6d3 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -3,6 +3,7 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; +import _ from 'underscore'; import CONST from '../../../../CONST'; import ONYXKEYS from '../../../../ONYXKEYS'; import ROUTES from '../../../../ROUTES'; From 2e2b5c89e0a22046789a9c4324eb2d2285c4a5fb Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Thu, 26 Oct 2023 00:28:15 +0700 Subject: [PATCH 06/10] fix logic update isSplitRequest --- src/libs/actions/IOU.js | 10 ++-------- .../MoneyRequestParticipantsSelector.js | 17 +++++------------ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 80a2fed6fe67..46b878941af4 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -2829,15 +2829,10 @@ function setMoneyRequestBillable(billable) { /** * @param {Object[]} participants - */ -function setMoneyRequestParticipants(participants) { - Onyx.merge(ONYXKEYS.IOU, {participants}); -} - -/** * @param {Boolean} isSplitRequest */ -function setMoneyRequestIsSplitRequest(isSplitRequest) { +function setMoneyRequestParticipants(participants, isSplitRequest) { + Onyx.merge(ONYXKEYS.IOU, {participants}); Onyx.merge(ONYXKEYS.IOU, {isSplitRequest}); } @@ -2948,7 +2943,6 @@ export { resetMoneyRequestTag, setMoneyRequestBillable, setMoneyRequestParticipants, - setMoneyRequestIsSplitRequest, setMoneyRequestReceipt, setUpDistanceTransaction, navigateToNextPage, diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index a98de08f7e4d..8cdabdaf6458 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -16,7 +16,6 @@ import CONST from '../../../../CONST'; import personalDetailsPropType from '../../../personalDetailsPropType'; import reportPropTypes from '../../../reportPropTypes'; import refPropTypes from '../../../../components/refPropTypes'; -import * as IOU from '../../../../libs/actions/IOU'; const propTypes = { /** Beta features list */ @@ -157,10 +156,10 @@ function MoneyRequestParticipantsSelector({ * @param {Object} option */ const addSingleParticipant = (option) => { - onAddParticipants([ - {accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true, searchText: option.searchText}, - ]); - IOU.setMoneyRequestIsSplitRequest(false); + onAddParticipants( + [{accountID: option.accountID, login: option.login, isPolicyExpenseChat: option.isPolicyExpenseChat, reportID: option.reportID, selected: true, searchText: option.searchText}], + false, + ); navigateToRequest(); }; @@ -199,13 +198,7 @@ function MoneyRequestParticipantsSelector({ }, ]; } - - if (newSelectedOptions.length === 0) { - IOU.setMoneyRequestIsSplitRequest(false); - } else { - IOU.setMoneyRequestIsSplitRequest(true); - } - onAddParticipants(newSelectedOptions); + onAddParticipants(newSelectedOptions, newSelectedOptions.length !== 0); }, [participants, onAddParticipants], ); From 3fd048d3bf71bbac35303f33d346cabd824d523f Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Thu, 26 Oct 2023 00:38:26 +0700 Subject: [PATCH 07/10] fix chore --- src/libs/actions/IOU.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 46b878941af4..74a852b29361 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -2832,8 +2832,7 @@ function setMoneyRequestBillable(billable) { * @param {Boolean} isSplitRequest */ function setMoneyRequestParticipants(participants, isSplitRequest) { - Onyx.merge(ONYXKEYS.IOU, {participants}); - Onyx.merge(ONYXKEYS.IOU, {isSplitRequest}); + Onyx.merge(ONYXKEYS.IOU, {participants, isSplitRequest}); } /** From 64780a1c2c270eab310ea8b5616dd8a9b189f72b Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Thu, 26 Oct 2023 09:48:14 +0700 Subject: [PATCH 08/10] Reset isSplitRequest when reset IOU --- src/libs/actions/IOU.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 74a852b29361..bfd7b7d2dfee 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -137,6 +137,7 @@ function resetMoneyRequestInfo(id = '') { receiptFilename: '', transactionID: '', billable: null, + isSplitRequest: false, }); } From 9df120e972aaf9d0ae040f08e575be7d225a127d Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Thu, 26 Oct 2023 09:59:48 +0700 Subject: [PATCH 09/10] fix lint --- .../MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index cefbd1d0c6d3..d83b562b0ba0 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -3,7 +3,6 @@ import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; -import _ from 'underscore'; import CONST from '../../../../CONST'; import ONYXKEYS from '../../../../ONYXKEYS'; import ROUTES from '../../../../ROUTES'; From d4bce7806be0ded476bfd9e686c2160fbe3207cd Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Fri, 27 Oct 2023 09:39:20 +0700 Subject: [PATCH 10/10] fix money request participants selector in manual --- .../MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index d83b562b0ba0..6dac11e70bfe 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -122,7 +122,7 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route}) { /> (optionsSelectorRef.current = el)} - participants={iou.participants} + participants={iou.isSplitRequest ? iou.participants : []} onAddParticipants={IOU.setMoneyRequestParticipants} navigateToRequest={() => navigateToConfirmationStep(iouType.current)} navigateToSplit={() => navigateToConfirmationStep(CONST.IOU.MONEY_REQUEST_TYPE.SPLIT)}