Skip to content

Commit

Permalink
Merge pull request #5254 from Santhosh-Sellavel/iou_participants_sear…
Browse files Browse the repository at this point in the history
…ch_validation_message

IOU Participant page search validation
  • Loading branch information
marcaaron authored Oct 18, 2021
2 parents dd9e492 + f736f55 commit a142eb2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,9 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma
return translate(preferredLocale, 'messages.noPhoneNumber');
}

if (!hasSelectableOptions && !hasUserToInvite) {
// 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');
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/NewChatPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -115,6 +115,11 @@ class IOUParticipantsRequest extends Component {

render() {
const sections = this.getSections();
const headerMessage = getHeaderMessage(
this.state.personalDetails.length + this.state.recentReports.length !== 0,
Boolean(this.state.userToInvite),
this.state.searchValue,
);
return (
<OptionsSelector
sections={sections}
Expand All @@ -139,6 +144,7 @@ class IOUParticipantsRequest extends Component {
personalDetails,
});
}}
headerMessage={headerMessage}
disableArrowKeysActions
hideAdditionalOptionStates
forceTextUnreadStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {withOnyx} from 'react-native-onyx';
import ONYXKEYS from '../../../../ONYXKEYS';
import styles from '../../../../styles/styles';
import OptionsSelector from '../../../../components/OptionsSelector';
import {getNewGroupOptions, isCurrentUser} from '../../../../libs/OptionsListUtils';
import {getHeaderMessage, getNewGroupOptions, isCurrentUser} from '../../../../libs/OptionsListUtils';
import CONST, {EXCLUDED_IOU_EMAILS} from '../../../../CONST';
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize';
import compose from '../../../../libs/compose';
Expand Down Expand Up @@ -198,6 +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(
this.state.personalDetails.length + this.state.recentReports.length !== 0,
Boolean(this.state.userToInvite),
this.state.searchValue,
) : '';
return (
<>
<View style={[styles.flex1, styles.w100]}>
Expand Down Expand Up @@ -230,6 +235,7 @@ class IOUParticipantsSplit extends Component {
personalDetails,
});
}}
headerMessage={headerMessage}
disableArrowKeysActions
hideAdditionalOptionStates
forceTextUnreadStyle
Expand Down

0 comments on commit a142eb2

Please sign in to comment.