Very often with contract law there is mostly no such thing as 'knowing a claim is not legally valid'. A lot of contract law is established by precedent, meaning in those cases nobody including the judge knew the enforceability of the issue before the judgement was written. Cases are also rarely identical examples of previous cases, meaning there can be an element of precedent setting even in cases that seem routine.