The fascinating part is that the rats did not open the compartment if the trap was empty or if it had a toy rat in it, demonstrating that the action was in fact to benefit another. See the differences in this video:

However, the rats did open the trap if something very precious to them was inside, such as chocolate chips. In a further experiment, Dr. Inbal Ben-Ami Bartal and researchers placed two compartments at the same time: in one they trapped its cage

mate and in the other one they placed chocolate chips. To their surprise, nearly 60% of the rats will free their mates first, then open the trap where the chocolate is, which eventually leads to sharing the chocolate chips. Empathy at its finest.