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

Don't check participants' whole names in default rooms #4141

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ SPEC CHECKSUMS:
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
EXHaptics: 337c160c148baa6f0e7166249f368965906e346b
FBLazyVector: 7b423f9e248eae65987838148c36eec1dbfe0b53
FBReactNativeSpec: e564123bce1111e84dc7aa0765fb1175f0c48aa0
FBReactNativeSpec: d65967936e86fe0fe6cca5c0125c237636868d4a
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the real problem here, but this should probably be updated according to this: https://expensify.slack.com/archives/C01GTK53T8Q/p1626728088492500

To fully confirm, can you also run pod install in the ios folder on the main branch and verify that you also get a different checksum? Also, run it on this branch, amal-participants-full-name-check, and it should give you the same checksum as me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a different checksum for a bunch of things

RNReanimated (2.3.0-alpha.1):
DoubleConversion: cde416483dac037923206447da6e1454df403714
FBReactNativeSpec: 76cede005e0667703f69105017804cc6c5e39fc8
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
RNReanimated: 833ebd229b31e18a8933ebd0cd744a0f47d88c42

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah hmm let me pull main into this branch and see if that resolves it. If not I might just not mess with this part.

Firebase: c23a36d9e4cdf7877dfcba8dd0c58add66358999
FirebaseAnalytics: 3bb096873ee0d7fa4b6c70f5e9166b6da413cc7f
FirebaseCore: d3a978a3cfa3240bf7e4ba7d137fdf5b22b628ec
Expand Down
13 changes: 7 additions & 6 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,18 @@ function createOption(personalDetailList, report, draftComments, {
* @param {String} searchValue
* @param {String} searchText
* @param {Set<String>} [participantNames]
* @param {Boolean} isDefaultChatRoom
* @returns {Boolean}
*/
function isSearchStringMatch(searchValue, searchText, participantNames = new Set()) {
function isSearchStringMatch(searchValue, searchText, participantNames = new Set(), isDefaultChatRoom = false) {
const searchWords = searchValue
.replace(/,/g, ' ')
.split(' ')
.map(word => word.trim());
return _.every(searchWords, (word) => {
const matchRegex = new RegExp(Str.escapeForRegExp(word), 'i');
const valueToSearch = searchText && searchText.replace(new RegExp(/&nbsp;/g), '');
return matchRegex.test(valueToSearch) || participantNames.has(word);
return matchRegex.test(valueToSearch) || (!isDefaultChatRoom && participantNames.has(word));
});
}

Expand Down Expand Up @@ -400,9 +401,9 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, {
}

// Finally check to see if this option is a match for the provided search string if we have one
const {searchText, participantsList} = reportOption;
const {searchText, participantsList, isDefaultChatRoom} = reportOption;
const participantNames = getParticipantNames(participantsList);
if (searchValue && !isSearchStringMatch(searchValue, searchText, participantNames)) {
if (searchValue && !isSearchStringMatch(searchValue, searchText, participantNames, isDefaultChatRoom)) {
continue;
}

Expand Down Expand Up @@ -449,9 +450,9 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, {
))) {
return;
}
const {searchText, participantsList} = personalDetailOption;
const {searchText, participantsList, isDefaultChatRoom} = personalDetailOption;
const participantNames = getParticipantNames(participantsList);
if (searchValue && !isSearchStringMatch(searchValue, searchText, participantNames)) {
if (searchValue && !isSearchStringMatch(searchValue, searchText, participantNames, isDefaultChatRoom)) {
return;
}
personalDetailsOptions.push(personalDetailOption);
Expand Down