Social dynamics drive selection in cooperative associations of ant queens