Skip to content

PM-4886 Update default state of talent search#1760

Open
himaniraghav3 wants to merge 7 commits intodevfrom
PM-4886
Open

PM-4886 Update default state of talent search#1760
himaniraghav3 wants to merge 7 commits intodevfrom
PM-4886

Conversation

@himaniraghav3
Copy link
Copy Markdown
Collaborator

@himaniraghav3 himaniraghav3 commented Apr 21, 2026

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/PM-4886

What's in this PR?

By default alphabetical order of users is shown in talent search UI
On searching for members through JD, we show skill filter search sorted by matching index


Open in Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 12 additional findings in Devin Review.

Open in Devin Review

Comment on lines +110 to +125
if (selectedCountryCodes.size > 0) {
const location = String(talent.location || '')
.trim()
const upperLocation = location.toUpperCase()
const lowerLocation = location.toLowerCase()
const matchesCountryCode = selectedCountryCodes.has(upperLocation)
|| Array.from(selectedCountryCodes)
.some(code => upperLocation.endsWith(` ${code}`))
const matchesCountryName = selectedCountryNames.some(name => (
lowerLocation === name || lowerLocation.endsWith(` ${name}`)
))

if (!matchesCountryCode && !matchesCountryName) {
return false
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Client-side country filter can drop valid results already filtered by server

Country codes are now sent server-side via payload.countries (TalentSearchPage.tsx:217-219), but the filteredResults memo also applies a client-side heuristic filter that matches against talent.location using endsWith. This dual filtering is problematic: the server filters by exact country code, but the client checks whether the location string ends with the country code or name. If the API returns a member whose location field doesn't follow the pattern "City, CODE" or "City, Country Name" (e.g., it's empty, just a city name, or uses a different separator like "/"), the client-side filter will drop valid results that the server correctly included.

Example of the problematic client-side filter

If the server returns a member with location: "New York" for a US-country-code filter, the client check at lines 115-120 will fail:

  • selectedCountryCodes.has("NEW YORK") → false
  • "NEW YORK".endsWith(" US") → false
  • "new york".endsWith(" united states") → false
    → The valid result is dropped.
Prompt for agents
The client-side country filter in filteredResults (lines 110-125) is now redundant with the server-side country filter added at lines 217-219 of runMemberSearch. The server receives exact country codes and handles filtering reliably, while the client filter uses fragile location-string matching that can produce false negatives.

The simplest fix is to remove the client-side country filter block entirely (lines 110-125 in filteredResults), since the server already handles country filtering via the countries parameter in the payload. The onlyActive and onlyOpenToWork client-side filters can remain as they are also server-side filtered and use exact boolean matching (no heuristics), so they are safe defensive checks.

Alternatively, if you want to keep the client-side country filter as a defensive measure, you could make it more lenient by using .includes() instead of .endsWith(), or by using the countryNameByCode map to resolve the location to a country code first and then matching against selectedCountryCodes.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant