Fix NilClass error when flattening required roles.