From 4f5e9f64949fe2779d381bf63d7326a083c0a047 Mon Sep 17 00:00:00 2001 From: Luckyman0305 Date: Wed, 9 Aug 2023 07:53:01 -0700 Subject: [PATCH 1/3] fix: Split bill - 'No results found' appears --- src/libs/OptionsListUtils.js | 7 +++++-- .../MoneyRequestParticipantsSplitSelector.js | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 826c5886f70d..29a3d57e6777 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -1006,9 +1006,10 @@ function getMemberInviteOptions(personalDetails, betas = [], searchValue = '', e * @param {Boolean} hasUserToInvite * @param {String} searchValue * @param {Boolean} [maxParticipantsReached] + * @param {Boolean} [hasMatchedParticipant] * @return {String} */ -function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, maxParticipantsReached = false) { +function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, maxParticipantsReached = false, hasMatchedParticipant = false) { if (maxParticipantsReached) { return Localize.translate(preferredLocale, 'common.maxParticipantsReached', {count: CONST.REPORT.MAXIMUM_PARTICIPANTS}); } @@ -1030,7 +1031,9 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma if (/@/.test(searchValue) && !isValidEmail) { return Localize.translate(preferredLocale, 'messages.errorMessageInvalidEmail'); } - + if (hasMatchedParticipant && (isValidEmail || isValidPhone)){ + return ''; + } return Localize.translate(preferredLocale, 'common.noResultsFound'); } diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js index 0c1376006271..9d29a56137e3 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js @@ -129,7 +129,7 @@ function MoneyRequestParticipantsSplitSelector({betas, participants, personalDet if (isOptionInList) { newSelectedOptions = _.reject(participants, (selectedOption) => selectedOption.accountID === option.accountID); } else { - newSelectedOptions = [...participants, {accountID: option.accountID, login: option.login, selected: true}]; + newSelectedOptions = [...participants, {accountID: option.accountID, login: option.login, selected: true, searchText: option.searchText}]; } onAddParticipants(newSelectedOptions); @@ -150,7 +150,8 @@ function MoneyRequestParticipantsSplitSelector({betas, participants, personalDet Boolean(newChatOptions.userToInvite), searchTerm, maxParticipantsReached, - ); + participants.filter(participant => participant.searchText.toLowerCase().includes(searchTerm.toLowerCase())).length > 0 + ); const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); useEffect(() => { From 4861ef975427c0127ffa5dbc55f866d49416d1be Mon Sep 17 00:00:00 2001 From: Luckyman0305 Date: Wed, 9 Aug 2023 11:53:57 -0700 Subject: [PATCH 2/3] fix: lint error --- .../MoneyRequestParticipantsSplitSelector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js index 9d29a56137e3..7d1aa5a8a230 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js @@ -150,7 +150,7 @@ function MoneyRequestParticipantsSplitSelector({betas, participants, personalDet Boolean(newChatOptions.userToInvite), searchTerm, maxParticipantsReached, - participants.filter(participant => participant.searchText.toLowerCase().includes(searchTerm.toLowerCase())).length > 0 + _.some(participant => participant.searchText.toLowerCase().includes(searchTerm.toLowerCase())) ); const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); From ba95ec6b35b0fd4d35a964096a2835f8c0414966 Mon Sep 17 00:00:00 2001 From: Luckyman0305 Date: Wed, 9 Aug 2023 13:21:52 -0700 Subject: [PATCH 3/3] fix: prettier error --- src/libs/OptionsListUtils.js | 2 +- .../MoneyRequestParticipantsSplitSelector.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 29a3d57e6777..769fc86204c6 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -1031,7 +1031,7 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma if (/@/.test(searchValue) && !isValidEmail) { return Localize.translate(preferredLocale, 'messages.errorMessageInvalidEmail'); } - if (hasMatchedParticipant && (isValidEmail || isValidPhone)){ + if (hasMatchedParticipant && (isValidEmail || isValidPhone)) { return ''; } return Localize.translate(preferredLocale, 'common.noResultsFound'); diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js index 7d1aa5a8a230..cfa7c0a8678c 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSplitSelector.js @@ -150,8 +150,8 @@ function MoneyRequestParticipantsSplitSelector({betas, participants, personalDet Boolean(newChatOptions.userToInvite), searchTerm, maxParticipantsReached, - _.some(participant => participant.searchText.toLowerCase().includes(searchTerm.toLowerCase())) - ); + _.some((participant) => participant.searchText.toLowerCase().includes(searchTerm.toLowerCase())), + ); const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); useEffect(() => {