Repository navigation
82304: Search - The workspace with the same name is not displayed in the autocomplete - #82784
Conversation
|
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a1073b768
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
PR ReviewThe approach is sound — using index-based substitution keys to disambiguate workspaces (and potentially other entities) that share the same display name is a clean solution. A few items to address: 1. Duplicated substitution-key logic — extract to a shared helperThe 8-line block that parses the query, counts same-key ranges, and builds the substitution key is copy-pasted identically between 2. Unsafe
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c02a00d48
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@aimane-chnaif Refactored code and added unit test cases. Thanks |
|
Are all AI reviews addressed? |
|
@aimane-chnaif, yes, all AI feedback is addressed. CI is failing because someone else made changes. I'll update it in the main. |
|
@aimane-chnaif PR is ready for review. Thanks. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.mov |
|
Please merge main |
Code ReviewThe approach of using indexed substitution keys ( Issues1. Unsafe type cast in const parsed = parseSearchQuery(newSearchQuery) as {ranges: Array<{key: string; value: string}>};This casts away the parser's return type. Use the actual 2. Duplicated substitution-update block still exists across two files
3. ID-based exclusion only covers workspace filter In NitIn |
Can you address? |
| text: value, | ||
| })); | ||
| } | ||
| case CONST.SEARCH.SYNTAX_FILTER_KEYS.POLICY_ID: { |
There was a problem hiding this comment.
@MelvinBot can you confirm all other filter logic is not affected by this PR?
Only CONST.SEARCH.SYNTAX_FILTER_KEYS.POLICY_ID should affect the production behavior.
|
Not entirely. The autocomplete suggestion filtering change is scoped to
This is backward-compatible when a filter+value appears only once (index 0 produces the same key as before). But if two different filter values resolve to the same display name (e.g., two categories named "Travel"), they now get separate keys instead of the second silently overwriting the first. That's arguably a fix, but it is a behavioral change beyond What would it take to scope the infrastructure to POLICY_ID only?The indexed-key logic in That said, the generic approach is safe due to the index-0 fallback, and will naturally extend to other filters if they ever need duplicate-name support. |
@aimane-chnaif I fixed Melvin's feedback. Can u check again? Thanks |
PR ReviewSummary: This PR fixes workspace search autocomplete so multiple workspaces sharing the same name can all be selected. It introduces index-based substitution keys ( Overall: Looks good. One correctness concern worth discussing, plus a few minor items. Correctness concern: positional remapping on deletion of non-last duplicateIn Example: three workspaces named "Test Workspace" → keys map to This is inherent to positional indexing with identical display values, and there may not be a clean fix without tracking IDs in the query itself. Since the previous behavior was that only one workspace could be selected per name, this is still a net improvement. But it's worth calling out — consider whether adding a brief code comment noting this limitation would help future readers. Minor items
TestsGood coverage — tests for all new utilities and the key integration point in Next Steps: Reply with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd0eed3b1d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| * Index 0 uses the base key for backward compatibility; index > 0 uses baseKey:index. | ||
| */ | ||
| const getSubstitutionMapKeyWithIndex = (filterKey: SearchFilterKey, value: string, index: number) => | ||
| index === 0 ? getSubstitutionMapKey(filterKey, value) : `${getSubstitutionMapKey(filterKey, value)}:${index}`; |
There was a problem hiding this comment.
Escape indexed substitution keys before appending suffix
getSubstitutionMapKeyWithIndex() appends :${index} directly to the serialized key, which makes indexed keys collide with legitimate values that already end in :<number>. For example, selecting workspace:"Foo" twice creates policyID:Foo:1, which is identical to the base key for a workspace literally named Foo:1; the later write overwrites the earlier mapping and getQueryWithSubstitutions() can submit the wrong policy IDs. Please make indexed keys unambiguous (e.g., structured encoding or a delimiter that cannot appear in values).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@abbasifaizan70 @aimane-chnaif could you please evaluate this comment?
There was a problem hiding this comment.
This is already fix above in previous comments of codex. @MariaHCD
There was a problem hiding this comment.
@abbasifaizan70 could you clarify how this was already addressed/fixed?
There was a problem hiding this comment.
@MariaHCD I tried the fallback Claude suggested (indexedKey ?? baseKey for duplicate occurrences), but it causes a correctness regression in real flow: after removing one same-name workspace and adding it back, the duplicate mapping becomes ambiguous, and an already-selected workspace can show again in suggestions.
For duplicate values, each occurrence must stay position-specific (base, :1, :2, ...). If we let non-zero indices fall back to the base key, multiple occurrences can resolve to the same policy ID, which breaks selected-ID exclusion.
So we only allow base-key fallback for the first occurrence (index === 0) and require indexed keys for duplicates. This keeps mapping deterministic and avoids the reappearing-duplicate issue.
|
@abbasifaizan70 could you kindly merge main here to fix the merge conflicts? Thanks! |
|
@MariaHCD Updated with main branch. |
|
🚧 @MariaHCD has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/MariaHCD in version: 9.3.61-0 🚀
Bundle Size Analysis (Sentry): |
|
I reviewed the changes in this PR against the help site articles under No help site changes are required. This PR is a bug fix for the search autocomplete — it corrects how workspaces with duplicate names are handled in the The existing help site articles (Using Search on the Reports Page and Using search operators) already document the |
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.3.61-4 🚀
|
Search - The workspace with the same name is not displayed in the autocomplete
Explanation of Change
Fixes Reports search so multiple workspaces that share the same name can all be picked from workspace: autocomplete by storing each choice under an index-based substitution key (policyID:Name, policyID:Name:1, …) instead of one key per name. It also keeps substitutions in sync when the query is edited (e.g. removing a duplicate) by remapping ordered IDs and by always applying the updated substitution map in the page header, including when it becomes empty.
Fixed Issues
$ #82304
PROPOSAL: #82304 (comment)
Tests
workspace:and verify the autocomplete list appears.Offline tests
Same as tests.
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-04-07.at.8.28.22.PM.mov
Android: mWeb Chrome
Screen.Recording.2026-04-07.at.8.18.41.PM.mov
iOS: Native
Screen.Recording.2026-04-07.at.8.13.18.PM.mov
iOS: mWeb Safari
Screen.Recording.2026-04-07.at.8.16.16.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-04-01.at.5.03.09.AM.mov