Domains: available domain is displayed as unavailable as the user keeps typing
Expected behavior
I would expect to be able to type an available desired domain entirely and still see it listed as an available domain.
Actual behavior
Available domain is shown as unavailable during a site creation if the user keeps typing to bring their desired domain into the screen.
Steps to reproduce the behavior
-
Add new site
-
Create WordPress.com site
-
Select any design
-
Type in a domain name (‘testingtfm3‘)
- Scroll down and check ‘testingtfm3.wordpress.com‘ is available
-
Continue typing to get more specific results (‘testingtfm3.w‘)
- Expected: ‘testingtfm3.wordpress.com‘ would appear closer to the top of the list and still available
- Observed: ‘testingtfm3.wordpress.com‘ is on top listed as unavailable

Tested on Samsung Galaxy Note20, Android 11, WPAndroid 18.0-rc-1
This issue seems to have few sides to it.
Firstly, the WP API seems to return the list of suggestions based on "sanitized" query, which is, I assume, just with the dot removed, i.e. "testingtfm3w" - see the fiddler screenshot.

Secondly, the WP app seems to have a different definition of "sanitized" query, which is dropping everything after the dot, i.e. "testingtfm3". This is what's getting looked up within the list of suggestions, returned by the WP API, and there's usually no match.
Lastly, the "domain unavailable" reporting is not exactly matching the entered query. App fails to find a sanitized query in the list off suggestion (based on differently sanitized query), whereas user has no awareness of sanitizing going on, and therefore gets an impression that either what's been typed is reported as unavailable, even though it actually is available (in case of "testingtfm3.w"), or what's reported as unavailable is not even what's been typed (in case of "testingtfm3.a") - see the app screenshots.


To fix that, sanitizing methods should be in sync between the API and the app (this could possibly be done without changing the backend, by sanitizing the query in the app before sending the API request). Then optionally (but desirably), depending on which way sanitizing goes - strips the dot, or drops everything after it - the app could either restrict the query entry to not allow dots (and other sanitized characters) or allow the full name search (including subdomains) respectively.
I've checked a bit the code behind the "domain unavailable" labelling in the code, and it seems @KirillPovarintsev's insights are valid, proving to be a good lead towards coming up with a fix.
Will continue from here, thanks for sharing 🥇 .
I've proposed a fix in https://github.com/wordpress-mobile/WordPress-Android/pull/17001 but we won't merge before checking with the A8c team since the proposal can be enhanced with a server side solution to be used both by the Android and iOS app.
Unassigned myself from this issue as I'm not actively working on it.
The proposed fix (https://github.com/wordpress-mobile/WordPress-Android/pull/17001) is better to be handled on the server side. The discussion on this has been moved internally to Automattic (ref: pbArwn-58N-p2)