Skip to content

Commit a142eb2

Browse files
authored
Merge pull request #5254 from Santhosh-Sellavel/iou_participants_search_validation_message
IOU Participant page search validation
2 parents dd9e492 + f736f55 commit a142eb2

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/libs/OptionsListUtils.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,9 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma
721721
return translate(preferredLocale, 'messages.noPhoneNumber');
722722
}
723723

724-
if (!hasSelectableOptions && !hasUserToInvite) {
724+
// Without a search value, it would be very confusing to see a search validation message.
725+
// Therefore, this skips the validation when there is no search value.
726+
if (searchValue && !hasSelectableOptions && !hasUserToInvite) {
725727
if (/^\d+$/.test(searchValue)) {
726728
return translate(preferredLocale, 'messages.noPhoneNumber');
727729
}

src/pages/NewChatPage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class NewChatPage extends Component {
123123
render() {
124124
const sections = this.getSections();
125125
const headerMessage = getHeaderMessage(
126-
this.state.personalDetails.length !== 0,
126+
this.state.personalDetails.length + this.state.recentReports.length !== 0,
127127
Boolean(this.state.userToInvite),
128128
this.state.searchValue,
129129
);

src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsRequest.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import {withOnyx} from 'react-native-onyx';
44
import _ from 'underscore';
5-
import {getNewChatOptions, isCurrentUser} from '../../../../libs/OptionsListUtils';
5+
import {getHeaderMessage, getNewChatOptions, isCurrentUser} from '../../../../libs/OptionsListUtils';
66
import OptionsSelector from '../../../../components/OptionsSelector';
77
import ONYXKEYS from '../../../../ONYXKEYS';
88
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize';
@@ -115,6 +115,11 @@ class IOUParticipantsRequest extends Component {
115115

116116
render() {
117117
const sections = this.getSections();
118+
const headerMessage = getHeaderMessage(
119+
this.state.personalDetails.length + this.state.recentReports.length !== 0,
120+
Boolean(this.state.userToInvite),
121+
this.state.searchValue,
122+
);
118123
return (
119124
<OptionsSelector
120125
sections={sections}
@@ -139,6 +144,7 @@ class IOUParticipantsRequest extends Component {
139144
personalDetails,
140145
});
141146
}}
147+
headerMessage={headerMessage}
142148
disableArrowKeysActions
143149
hideAdditionalOptionStates
144150
forceTextUnreadStyle

src/pages/iou/steps/IOUParticipantsPage/IOUParticipantsSplit.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {withOnyx} from 'react-native-onyx';
66
import ONYXKEYS from '../../../../ONYXKEYS';
77
import styles from '../../../../styles/styles';
88
import OptionsSelector from '../../../../components/OptionsSelector';
9-
import {getNewGroupOptions, isCurrentUser} from '../../../../libs/OptionsListUtils';
9+
import {getHeaderMessage, getNewGroupOptions, isCurrentUser} from '../../../../libs/OptionsListUtils';
1010
import CONST, {EXCLUDED_IOU_EMAILS} from '../../../../CONST';
1111
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize';
1212
import compose from '../../../../libs/compose';
@@ -198,6 +198,11 @@ class IOUParticipantsSplit extends Component {
198198
render() {
199199
const maxParticipantsReached = this.props.participants.length === CONST.REPORT.MAXIMUM_PARTICIPANTS;
200200
const sections = this.getSections(maxParticipantsReached);
201+
const headerMessage = !maxParticipantsReached ? getHeaderMessage(
202+
this.state.personalDetails.length + this.state.recentReports.length !== 0,
203+
Boolean(this.state.userToInvite),
204+
this.state.searchValue,
205+
) : '';
201206
return (
202207
<>
203208
<View style={[styles.flex1, styles.w100]}>
@@ -230,6 +235,7 @@ class IOUParticipantsSplit extends Component {
230235
personalDetails,
231236
});
232237
}}
238+
headerMessage={headerMessage}
233239
disableArrowKeysActions
234240
hideAdditionalOptionStates
235241
forceTextUnreadStyle

0 commit comments

Comments
 (0)