Jack is considering the "worst case", the case where he is "as unlucky as possible", but which gives him the mathematical certainty that he has picked at least 8 balls of the same color.
what may happen, if Jack is very very unlucky, is that he may pick 7 white balls, 7 green balls and 7 red balls, so 7*3=21 in total.
The 22nd will either be white, green or red, so he will have picked 8 balls of the same color.
Answer: 22