From 3a3bbd2cebb061c7c55ff4926706f5ebaec6360f Mon Sep 17 00:00:00 2001 From: Santhoshkumar Sellavel Date: Wed, 15 Sep 2021 01:09:42 +0530 Subject: [PATCH 1/4] IOU Participant page search validation --- src/libs/OptionsListUtils.js | 2 +- .../steps/IOUParticipantsPage/IOUParticipantsRequest.js | 8 +++++++- .../iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 1ad67c2236b8..bc0d142dfc91 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -719,7 +719,7 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma return translate(preferredLocale, 'messages.noPhoneNumber'); } - if (!hasSelectableOptions && !hasUserToInvite) { + if (searchValue && !hasSelectableOptions && !hasUserToInvite) { if (/^\d+$/.test(searchValue)) { return translate(preferredLocale, 'messages.noPhoneNumber'); } diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js index ead69898fdad..d48a4eb87237 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js @@ -2,7 +2,7 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import {getNewChatOptions, isCurrentUser} from '../../../../libs/OptionsListUtils'; +import {getHeaderMessage, getNewChatOptions, isCurrentUser} from '../../../../libs/OptionsListUtils'; import OptionsSelector from '../../../../components/OptionsSelector'; import ONYXKEYS from '../../../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; @@ -115,6 +115,11 @@ class IOUParticipantsRequest extends Component { render() { const sections = this.getSections(); + const headerMessage = getHeaderMessage( + this.state.personalDetails.length !== 0, + Boolean(this.state.userToInvite), + this.state.searchValue, + ); return ( @@ -230,6 +235,7 @@ class IOUParticipantsSplit extends Component { personalDetails, }); }} + headerMessage={headerMessage} disableArrowKeysActions hideAdditionalOptionStates forceTextUnreadStyle From 2845143b309efe514fa142df57dfe4e871e344a8 Mon Sep 17 00:00:00 2001 From: Santhoshkumar Sellavel Date: Fri, 17 Sep 2021 21:52:42 +0530 Subject: [PATCH 2/4] Added a comment for the searchValue check --- src/libs/OptionsListUtils.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index bc0d142dfc91..8c8f598caec3 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -719,6 +719,8 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma return translate(preferredLocale, 'messages.noPhoneNumber'); } + // Without a search value, it would be very confusing to see a search validation message. + // Therefore, this skips the validation when there is no search value. if (searchValue && !hasSelectableOptions && !hasUserToInvite) { if (/^\d+$/.test(searchValue)) { return translate(preferredLocale, 'messages.noPhoneNumber'); From 9d190f09831d3ec19bf4a32227c8eb4e8dc32c1c Mon Sep 17 00:00:00 2001 From: Santhoshkumar Sellavel Date: Fri, 8 Oct 2021 00:59:45 +0530 Subject: [PATCH 3/4] No results for invalid cases handled --- src/pages/NewChatPage.js | 2 +- .../iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js | 2 +- .../iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index c21888389af0..2c5ac5676f51 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -123,7 +123,7 @@ class NewChatPage extends Component { render() { const sections = this.getSections(); const headerMessage = getHeaderMessage( - this.state.personalDetails.length !== 0, + this.state.personalDetails.length + this.state.recentReports.length !== 0, Boolean(this.state.userToInvite), this.state.searchValue, ); diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js index d48a4eb87237..a277528530cd 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js @@ -116,7 +116,7 @@ class IOUParticipantsRequest extends Component { render() { const sections = this.getSections(); const headerMessage = getHeaderMessage( - this.state.personalDetails.length !== 0, + this.state.personalDetails.length + this.state.recentReports.length !== 0, Boolean(this.state.userToInvite), this.state.searchValue, ); diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js index d422819b7c76..af363c2fbf48 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js @@ -198,8 +198,8 @@ class IOUParticipantsSplit extends Component { render() { const maxParticipantsReached = this.props.participants.length === CONST.REPORT.MAXIMUM_PARTICIPANTS; const sections = this.getSections(maxParticipantsReached); - const headerMessage = getHeaderMessage( - this.state.personalDetails.length !== 0, + const headerMessage = maxParticipantsReached ? '' : getHeaderMessage( + this.state.personalDetails.length + this.state.recentReports.length !== 0, Boolean(this.state.userToInvite), this.state.searchValue, ); From f736f5559b3ab4779e3f157e0101b5df717b9927 Mon Sep 17 00:00:00 2001 From: Santhoshkumar Sellavel <85645967+Santhosh-Sellavel@users.noreply.github.com> Date: Fri, 8 Oct 2021 11:44:56 +0530 Subject: [PATCH 4/4] Swapped message condition --- .../iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js index af363c2fbf48..7976850770d5 100755 --- a/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js +++ b/src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js @@ -198,11 +198,11 @@ class IOUParticipantsSplit extends Component { render() { const maxParticipantsReached = this.props.participants.length === CONST.REPORT.MAXIMUM_PARTICIPANTS; const sections = this.getSections(maxParticipantsReached); - const headerMessage = maxParticipantsReached ? '' : getHeaderMessage( + const headerMessage = !maxParticipantsReached ? getHeaderMessage( this.state.personalDetails.length + this.state.recentReports.length !== 0, Boolean(this.state.userToInvite), this.state.searchValue, - ); + ) : ''; return ( <>