Refactor milestone selection code for iteration box.

We can't just pick the last numbered milestone in the list, because
sometimes the milestone for the next iteration will be there before that
iteration has started.