First of all, it’s not possible that both Tom and Dick have green. If they had, Harry would know immediately that he had white because all the greens would already have gone; he wouldn’t have to contemplate. For the same reason, neither both Tom and Harry nor both Dick and Harry can have green, because then the third one would know he had white (remember, green only twice!). So there’s maximum one green hat circulating, and at least two, maybe three white ones.
Now let’s imagine Tom was the only one to have green. He sees white twice, so he can’t tell his own color. He says so. Dick sees one white (Harry) and one green hat (Tom); he can’t tell. But if he himself were wearing green, there would be two green hat circulating, which is impossible. because then Tom would have known his color. So Dick would know he had white. Impossible.
If Harry was the only one to wear green, both Tom and Dick would each see one white and one green hat. Harry would say he doesn’t know, but Dick would know he had white (because he sees Harry’s green hat, too, and if he had green, Tom would have known he, Tom, had white). Impossible.
If Dick was the only one to wear green, Tom would see one white, one green, and wouldn’t be able to tell his color. Dick would see two white hats, and couldn’t tell his own color either. Harry would know he had white, however, because if he had green Tom (who would see Dick’s green hat, too) would have known he had white. But he didn’t. So this scenario works out well.
If all three boys were wearing white hats, each of them would see two white hats. Tom wouldn’t be able to tell his color; Dick wouldn’t be able, either, and the fact that Tom said he didn’t know doesn’t help him because Tom wouldn’t know if Dick had green, either. Harry, too, can’t tell, and the information that the other guys didn’t know their own colors wouldn’t help him. So nobody could tell. Impossible.
So in the end, the scenario where Dick has green and Tom and Harry white is the only one that works out.