What he did is correct. He is not liable to pay Khums for the amount that he paid towards the hajj. Since the year before he has paid for the Khums, and his money towards the hajj was from money that Khums had been paid on. The hajj is valid and there is no issue. Khums is due on whatever is extra. The money he paid towards hajj was not with him and couldn’t have possibly been with him since he had to pay for the hajj expenses a couple of months before the hajj.