Skip to content

Commit

Permalink
Merge pull request #24548 from blazejkustra/feature/search-reports-by-id
Browse files Browse the repository at this point in the history
Add the ability to search for rooms by reportID in NewDot
  • Loading branch information
puneetlath authored Aug 21, 2023
2 parents 298ae29 + eb5ccaa commit dd50e91
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,17 @@ function getOptions(
// Finally check to see if this option is a match for the provided search string if we have one
const {searchText, participantsList, isChatRoom} = reportOption;
const participantNames = getParticipantNames(participantsList);
if (searchValue && !isSearchStringMatch(searchValue, searchText, participantNames, isChatRoom)) {
continue;

if (searchValue) {
// Determine if the search is happening within a chat room and starts with the report ID
const isReportIdSearch = isChatRoom && Str.startsWith(reportOption.reportID, searchValue);

// Check if the search string matches the search text or participant names considering the type of the room
const isSearchMatch = isSearchStringMatch(searchValue, searchText, participantNames, isChatRoom);

if (!isReportIdSearch && !isSearchMatch) {
continue;
}
}

recentReportOptions.push(reportOption);
Expand Down Expand Up @@ -1044,7 +1053,7 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma

const isValidEmail = Str.isValidEmail(searchValue);

if (searchValue && CONST.REGEX.DIGITS_AND_PLUS.test(searchValue) && !isValidPhone) {
if (searchValue && CONST.REGEX.DIGITS_AND_PLUS.test(searchValue) && !isValidPhone && !hasSelectableOptions) {
return Localize.translate(preferredLocale, 'messages.errorMessageInvalidPhone');
}

Expand Down

0 comments on commit dd50e91

Please sign in to comment.