makes perfect sense @Stephen, thanks for clarifying.
I think we could just alter the import script to do something like:
username_original = username
username = @htmlentities.decode(user["username"]).strip
{
id: user["userid"],
name: username_original,
username: username,
password: password,
[...]
And in the discourse setting enable the priority for the user “name”, if it’s present, over the username.