Can you solve the Pinocchio "green hats" logic puzzle?

IMO, if he has no hats… then saying that these hats he doesn’t have are green just makes it even more of a lie. They’re imaginary hats at that point and any reference to them would be imaginary as well… or a lie.