Skip to content

[$175] Android - Imported contacts cannot be found when searching by special characters or emojis #105054

Closed as not planned

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.5.20-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/folder/13176722/test-cases/41237029
Email or phone of affected tester (no customers): setowskiw+15@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Samsung Galaxy S21 FE/Android 16
App Component: Other

Action Performed:

Preconditions: Device contacts contain special characters or emojis in their names.

  1. Launch Expensify app
  2. Tap Scan
  3. Tap Submit field
  4. Tap Import contacts
  5. Tap the search field and enter a special character e.g., ! that is present in a contact's name
  6. Repeat the search using an emoji that is present in another contact's name

Expected Result:

Searching for contacts using special characters or emojis in their names should return the matching contacts.

Actual Result:

Contacts containing special characters or emojis are displayed correctly in the imported contacts list. However, searching for these contacts using the special characters or emojis in their names returns "No results found", even though the contacts are present in the list.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7297186_1793035637954.Recording_2026-10-26_181951.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7297186

Upwork Automation - Do Not Edit

Activity

  1. added
    Daily
    Bug
    on Oct 26, 2026
  2. applause-bot commented on Oct 26, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/7482e8385271ab81360374f206cf91a5c34c49d7a1307ff7c769c69d74aa2e4b

  3. MelvinBot commented on Oct 26, 2026

    @MelvinBot
    Contributor

    ⚠️ Preliminary analysis (low confidence) — treat as a starting point, not a conclusion.

    I don't think the App's search drops special characters or emojis. I think the contact list the tester saw on Android 16 wasn't the App's list.

    Migrate to Android Contact Picker and remove READ_CONTACTS shipped to production in 9.5.8-5. Since then, the App no longer reads the whole address book on Android:

    If no contact was picked, the App holds no device contacts. Then any search shows "No results found", even one using letters from a contact's name. The regression test case was probably written for the old bulk import.

    I wasn't able to fully verify this. I couldn't watch the video or run the matcher in this environment. To confirm, check:

    1. Was a contact with an email address actually picked and shown in the App's list before searching?
    2. Did "No results found" come from Expensify's search field, or from the Samsung picker's search?
    3. If a picked contact named, for example, "Bob!" can't be found by searching "!" in the App, the problem is real App behavior. Reply here and I'll dig into the matcher.

    If the answer to 1 is no, update the regression test case for the picker flow. No App code change is needed.

    Why the search code looks correct

    Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.

  4. added
    External
    on Oct 26, 2026
  5. melvin-bot commented on Oct 26, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @QichenZhu (External)

  6. changed the title [-]Android - Imported contacts cannot be found when searching by special characters or emojis[/-] [+][$175] Android - Imported contacts cannot be found when searching by special characters or emojis[/+] on Oct 26, 2026
  7. melvin-bot commented on Oct 26, 2026

    @melvin-bot
  8. camesenin commented on Oct 26, 2026

    @camesenin
  9. melvin-bot commented on Oct 26, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  10. shilo1979jk commented on Oct 26, 2026

    @shilo1979jk

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Android (v9.5.20-0, Samsung Galaxy S21 FE / Android 16), when following the regression test steps (Launch Expensify app → Tap Scan → Tap Submit field → Tap Import contacts) and searching for contacts containing special characters (e.g. !, )) or emojis (e.g. 🥰, 😀) in their names, "No results found" is displayed even though the contacts are visible in the list before searching.

    What is the root cause of that problem?

    Frame-by-frame inspection of the attached reproduction video (frame_001.jpg–frame_027.jpg) together with the Expensify/App contact picker and search implementation explains what happens:

    1. No contact was picked or imported into Expensify before searching (answers Verification Question 1):

      • In frame_001.jpg, the tester is on Expensify's Choose recipient screen (src/pages/iou/request/ParticipantSearchResults.tsx) after navigating via Scan → Submit, and taps the Import contacts row (MenuItemNavigation at ParticipantSearchResults.tsx:530-536).
      • Since PR #102928 (shipped in 9.5.8-5), android.permission.READ_CONTACTS was removed on Android (src/libs/ContactImport/index.android.tsx:6-11), and tapping Import contacts invokes contactState.pickContact() (src/hooks/useContactImport.ts:49-61 → src/libs/ContactPicker/index.android.ts:9-16 → HybridContactsModule.pick() at modules/ExpensifyNitroUtils/android/src/main/java/com/margelo/nitro/utils/contacts/HybridContactsModule.kt:68-92).
      • On Android 16 and lower (Build.VERSION.SDK_INT < 37, where CONTACTS_PICKER_MIN_SDK = 37 at HybridContactsModule.kt:210), createPickIntent() (HybridContactsModule.kt:94-117) launches the system/OEM contacts app's email picker via:
        val contentType = if (keys.contains(ContactFields.EMAIL_ADDRESSES)) Email.CONTENT_TYPE else Phone.CONTENT_TYPE
        return Intent(Intent.ACTION_PICK).setType(contentType)
      • In frame_002.jpg–frame_003.jpg, the external < Select contact | Cancel picker screen opens and lists the device contacts under section & (!123!! / setowskiw+88@gmail.com, @!))&😀 / rt!+24@gmail.com, and 🥰 / asd@gmail.com). Throughout the entire recording (frame_002.jpg–frame_027.jpg), the tester never taps a contact row to return a selection (onActivityResult in HybridContactsModule.kt:30-51) back to Expensify.
    2. "No results found" in the video comes from the external Samsung Contacts picker screen, not from Expensify's search field (answers Verification Question 2):

      • Every search in the video (frame_006.jpg–frame_027.jpg) is typed into the Search bar of the < Select contact | Cancel picker activity:
        • frame_008.jpg: searching 🥰 → the external picker displays "No results found".
        • frame_016.jpg: searching @ → the external picker matches the three contacts whose email addresses contain @gmail.com.
        • frame_020.jpg: searching ) → the external picker displays "No results found".
        • frame_026.jpg: searching a → the external picker matches the three contacts whose email addresses contain a (asd@gmail.com, annawanna9879@gmail.com, aaa@gmail.com).
      • That search bar belongs to the device's external Contacts app launched by Intent.ACTION_PICK, which ignores punctuation/emoji queries like 🥰 and ) and is outside Expensify's control.
    3. How Expensify's own search behaves once a contact is picked (Verification Question 3):

      • Because the recording ends inside the external picker without selecting a contact, Expensify's own search field is never exercised in the video.
      • Static inspection of Expensify's contact import and search pipeline confirms that once a contact is tapped in the picker, readPickedDataRow() (HybridContactsModule.kt:161-176) returns DISPLAY_NAME_PRIMARY and DATA1 (email) to useContactImport.pickContact() (src/hooks/useContactImport.ts:49-61), which builds the option via getContactsExtended() (src/libs/ContactUtils.ts:84-93) and getContactOption() (src/libs/PersonalDetailOptionsListUtils/index.ts:139-183) and merges it into optionsWithContacts (src/hooks/useSearchSelector/base.ts:242-280).
      • When searching in Expensify's Choose recipient input (Name, email, or phone number), getSearchValueForPhoneOrEmail() (src/libs/OptionsListUtils/index.ts:909-912), processSearchString() (src/libs/OptionsListUtils/index.ts:3464-3469), filterPersonalDetails() (src/libs/OptionsListUtils/index.ts:3194-3203), doesPersonalDetailMatchSearchTerm() (src/libs/OptionsListUtils/searchMatchUtils.ts:36-64), and getMatchRanking() (src/libs/filterArrayByMatch.ts:27-62) normalize strings using StringUtils.normalizeForMatch() (src/libs/StringUtils/index.ts:113-145) and lodash/deburr. Those normalizers only strip combining diacritical marks (\u0300-\u036f) and zero-width characters (\u200b\u2060\ufeff), preserving special characters and emojis in displayName / text.

    What changes do you think we should make in order to solve the problem?

    1. No Expensify application code change is needed, because replacing bulk READ_CONTACTS access on Android with the system contact picker (Intent.ACTION_PICK on Android ≤ 16, ContactsPickerSessionContract.ACTION_PICK_CONTACTS on Android 17+) in PR #102928 (9.5.8-5) is intentional, and the search bar shown in the video belongs to the OS contacts picker rather than Expensify.
    2. Update BrowserStack regression test case #41237029 for Android so that the tester first picks the contact(s) in the system picker before testing Expensify's search field on the Choose recipient screen:
      • Preconditions: Device contacts contain contacts with special characters (e.g. !123!! with setowskiw+88@gmail.com) and emojis (e.g. 🥰 with asd@gmail.com) in their names and valid email addresses.
      • Step 1: Launch the Expensify app.
      • Step 2: Tap Scan.
      • Step 3: Tap the Submit field (opening the Choose recipient screen).
      • Step 4: Tap Import contacts to open the system contact picker, and select the contact(s) containing special characters and emojis so they are imported into Expensify's Contacts list on the Choose recipient screen (on Android 16 and lower, ACTION_PICK imports one contact per pick, so repeat Import contacts if importing multiple test contacts; on Android 17+, multi-select is supported).
      • Step 5: On Expensify's Choose recipient screen, tap Expensify's search field (Name, email, or phone number) and enter a special character (e.g. !) present in the imported contact's name — verify the matching imported contact is returned.
      • Step 6: Repeat the search in Expensify's search field using an emoji (e.g. 🥰) present in the imported contact's name — verify the matching imported contact is returned, and verify that searching for a non-matching special character/emoji displays "No results found".

    What alternative solutions did you explore? (Optional)

    • We checked whether Android 16 (SDK_INT = 36) offers another permissionless contact picker intent with different search behavior. ContactsPickerSessionContract.ACTION_PICK_CONTACTS requires Android 17 (CONTACTS_PICKER_MIN_SDK = 37, HybridContactsModule.kt:95,210); on Android 16 and lower, Intent(Intent.ACTION_PICK).setType(Email.CONTENT_TYPE) (HybridContactsModule.kt:115-116) is the only permissionless contact picker available.
    • We also checked whether src/libs/Firebase/queries/Onyx/Contact.ts (referenced in another proposal on this issue) exists in Expensify/App; no such file or filterContact function exists in the repository.
  11. weaieverything commented on Oct 26, 2026

    @weaieverything

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Android, searching imported device contacts by a special character or emoji in their name returns no results, even though those contacts show correctly in the list.

    What is the root cause of that problem?

    Contact options are built in src/libs/ContactUtils.ts (getContacts, lines ~45–60) through getContactOption → createOption in src/libs/PersonalDetailOptionsListUtils/index.ts. Their searchText is deburr(${result.text} ${result.login}.toLocaleLowerCase()) (line 92). They are matched in matchesSearchTerms (line 242), which runs searchText.includes(term) against terms from processSearchString (src/libs/OptionsListUtils/index.ts:3464). That function uses deburr(...).toLowerCase().

    The two sides are normalized differently. Android contact providers return names in decomposed / compatibility form (NFD, emoji with or without U+FE0F variation selectors and U+200D ZWJ sequences, keycap U+20E3, which deburr strips as a combining mark on one side). The keyboard inserts the composed form, and toLowerCase and toLocaleLowerCase are also used asymmetrically. So includes compares different code-unit sequences that render identically, and the match fails.

    What changes do you think we should make in order to solve the problem?

    Add one shared normalizer and use it for both the option searchText and the search terms:

    // src/libs/OptionsListUtils/index.ts
    function normalizeForSearch(value: string): string {
        return deburr(value.normalize('NFKC'))
            .replaceAll(/[\uFE0E\uFE0F\u200D]/g, '')
            .toLocaleLowerCase();
    }
    
    function processSearchString(searchString: string | undefined): string[] {
        return normalizeForSearch(searchString ?? '')
            .split(/\s+/)
            .filter((term) => term.length > 0);
    }
    // src/libs/PersonalDetailOptionsListUtils/index.ts (line 92 and the fallback at line 248)
    result.searchText = normalizeForSearch(`${result.text} ${result.login ?? ''}`);

    This also fixes the same mismatch for regular personal details, and splitting on /\s+/ handles non-breaking spaces that Android keyboards sometimes insert.

    What alternative solutions did you explore? (Optional)

    Escaping or regex-matching terms. Not needed, because matching uses includes and not a regex. Note: I could not reproduce on a physical Android device. I'd verify with a contact named Bob! and Ana 😀 before the PR.

  12. bhomvratrai-glitch commented on Oct 27, 2026

    @bhomvratrai-glitch

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Android, when searching imported device contacts by entering a special character (e.g. !) or an emoji that exists in a contact's display name, the list returns "No results found" even though the contact displays correctly in the un-filtered list.

    What is the root cause of that problem?

    There are two interconnected causes in the contact search and filtering pipeline:

    1. Missing Name Search Field for Imported Contacts in getPersonalDetailSearchTerms:
      In src/libs/OptionsListUtils/searchMatchUtils.ts (lines 36–41), getPersonalDetailSearchTerms constructs searchable terms for options:
    return [item.participantsList?.[0]?.displayName ?? item.displayName ?? '', item.login ?? '', item.login?.replace(CONST.EMAIL_SEARCH_REGEX, '') ?? ''];

    For imported device contacts created in src/libs/PersonalDetailOptionsListUtils/index.ts via createOption() (lines 76–80), the contact's name is assigned to result.text rather than result.displayName, and item.participantsList is undefined. Because item.displayName is undefined on OptionData, getPersonalDetailSearchTerms evaluates item.participantsList?.[0]?.displayName ?? item.displayName ?? '' to an empty string ''. As a result, filterPersonalDetails and ranking algorithms only compare the search query against the contact's email/phone login instead of their display name.

    1. Single Character Special/Emoji Handling in processSearchString and getMatchRanking:
      In src/libs/OptionsListUtils/index.ts (line 3465), processSearchString normalizes search queries via deburr(searchString ?? '').toLowerCase().split(' '). When a user types a standalone special character or emoji, StringUtils.normalizeForMatch in src/libs/filterArrayByMatch.ts passes the character through, but because the contact's item.text was omitted from getPersonalDetailSearchTerms, the ranker calculates MATCH_RANK.NO_MATCH and drops the contact.

    What changes do you think we should make in order to solve the problem?

    1. In src/libs/OptionsListUtils/searchMatchUtils.ts:
      Update getPersonalDetailSearchTerms to include item.text:
    return [item.text ?? item.participantsList?.[0]?.displayName ?? item.displayName ?? '', item.login ?? '', item.login?.replace(CONST.EMAIL_SEARCH_REGEX, '') ?? ''];

    This ensures imported contacts (which store their full formatted name in item.text) have their display name included in rankable search terms alongside real Onyx personal details.

    1. In src/libs/PersonalDetailOptionsListUtils/index.ts:
      In createOption, assign result.displayName = userDetails.displayName ?? result.text; (or keep displayName on the returned option) to ensure parity across all option consumers that inspect displayName vs text.

    2. In src/libs/OptionsListUtils/index.ts:
      In getValidOptions, ensure doesPersonalDetailMatchSearchTerm uses useLocaleLowerCase: true and includes personalDetail.text when matching special characters and multi-byte emoji sequences.

    What alternative solutions did you explore? (Optional)

    We explored modifying only StringUtils.normalizeForMatch to strip punctuation, but that would break legitimate special-character and emoji matching in contacts. Feeding item.text into getPersonalDetailSearchTerms directly addresses the root omission with zero regressions to existing chat or report search rankings.

    Contributor details
    Your Expensify account email: bhomvratrai@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~016c1aa34b51059d42

  13. 9 remaining items

  14. QichenZhu commented on Nov 3, 2026

    @QichenZhu
    Contributor

    @AndrewGable, could you take a look at this comment?

  15. melvin-bot commented on Nov 3, 2026

    @melvin-bot

    @QichenZhu Huh... This is 4 days overdue. Who can take care of this?

  16. melvin-bot commented on Nov 6, 2026

    @melvin-bot

    @QichenZhu Whoops! This issue is 2 days overdue. Let's get this updated quick!

  17. melvin-bot commented on Nov 9, 2026

    @melvin-bot

    @QichenZhu this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

  18. QichenZhu commented on Nov 10, 2026

    @QichenZhu
    Contributor

    @AndrewGable friendly bump on this comment. Thanks!

  19. expensify-chore-bot commented on Nov 17, 2026

    @expensify-chore-bot

    @QichenZhu Still overdue 6 days?! Let's take care of this!

  20. expensify-chore-bot commented on Nov 19, 2026

    @expensify-chore-bot

    @QichenZhu 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  21. QichenZhu commented on Nov 20, 2026

    @QichenZhu
    Contributor

    Closing for now. Feel free to reopen if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions