According to IFAB rules, a handball cannot be penalized if the ball directly touches the hand from the player's own head or body or the head/body of another nearby player (including a teammate). The logic is simple: after cooking, the ball flies too close and too fast, the defender does not have time to react, so such contact is not considered a violation as long as the hand does not move towards the ball.
Nuances when a violation can still be counted:.
If the player himself directed his hand towards the ball - for example, he noticed the ball and took it out;.
If the hand is in an unnatural position, artificially increasing the size of the body (torn from the body, extended to the sides) - and the ball hits it not from the head/body of that player, but after contact with an opponent.
So the scenario "you hit your head the ball hits your partner's hand" is almost always clean, the game continues. The referee can only give a foul if the arm is clearly outstretched in an unnatural way or the player is swinging it.