Take one for the team

(v.) To subject oneself to physical or mental anguish so that others do not suffer in the same way.

Definition link