getUserByKey(<username>) is not working when change the user name. Its return in active user

All,

I have created custom post function from open to in progress.

I have used the one active user(newtest) to pre-populate in one of the fields in the post function. It is working fine when I transition.

However, I have changed the user name to newtest_old, made it inactive, and created a new user with the same name. I have done it through the admin ui.

Now, I ran the transition and check the user name it returns an inactive user in Jira710 and Jira7130. In jira840 it is blank, as per the below code, getting user by getUserByName() and works fine.

Note: This issue is on Jira 710 version and 713 versions not on jira84.0

I am using jira7.0.0 api version code snippet which I used as below:

ApplicationUser user = ComponentAccessor.getUserManager().getUserByKey(name);

    if (user == null) { // try lookup by name instead of key

        user = ComponentAccessor.getUserManager().getUserByName(name);

    }

Could you please help me understand is there any issue with getUserByKey() on Jira 710 and 7130 versions?

or

When can I use getUserByKey() and getUserByName()?

Thanks,