Unemployed villagers and nitwits shake their heads when the player attempts to trade with them, which is not the problem. The potential problem is that an employed villager will do the same animation when attempted to be traded with. Trading seems to still work though, and the problem only seems to happen after a trading attempt has been made while unemployed. The problem goes away after leaving and reentering the world (at least in singleplayer).
Duplicate of MC-147479.