Hello!
Discourse and edx constraints on username are different, and there are at least two cases when discourse user can't be created from valid edx username.
edx username contains double underscore, e.g. "name__surname"
discourse username ends on underscore, e.g. "namesurname". Case can happen because of 20-symbol cutoff in discourse.
This PR fixes mentioned cases, however there could be more, I haven't checked.
We have faced these problems several times because at our instance edx usernames are generated from email, and all special symbols are replaced by underscores.
Hello! Discourse and edx constraints on username are different, and there are at least two cases when discourse user can't be created from valid edx username.