Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOU Participant page search validation #5254

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,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
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 !== 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 = getHeaderMessage(
this.state.personalDetails.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