I had this weird error when I tried to restore some directadmin accounts on new server. Majority of accounts were restored successfully, but some returned this error:
user1 is not a valid username user2 is not a valid username
I tried many things and than found out that there is default setting for username length in directadmin configuration max_username_length. Default value is 10, so if your username of account that you are trying to restore is larger than 10 characters, error will be returned. You have to edit directadmin configuration and set this variable.
[root@mx ~]# vi /usr/local/directadmin/conf/directadmin.conf
then edit max_username_length to larger value. I my example 20.