Make sure that the membership is valid before rendering

This prevents 500 errors when certain pieces of information about a
membership are missing or they refer to records that no longer exist.