The thing is without this change, the task could not be finish. You are thinking of this changes as a hack, but it is an improvement of code. Also this improvement is not ugly, and it fits well with the rest of the code of that function. I still think we should merge the change, and then refactor that function is a separated commit.

I don't share your view. Once the change is in ... you can change it after, code refactoring.