I have seen numerous cases where the person implementing the code is rewarded and next one comes along, and rewrites the code since first one is too hard to change. He gets rewarded too and cycle continues.
It's cognitively easier for the boss to lean on what is easy (observed time in office). Unfortunate, and like all cognitive biases, we need to teach them, so people can work around them.
There is a big danger to the super cushy corporations: they make work almost as pleasant (for a certain set of vanilla employees) as being at home / out and about. This enables those vanilla employees to happily spend way more than 40 hours in office. Obviously the management must think this is good... but is it?
I suspect the vanilla individuals spending all that time in the office are benefiting from the cognitive bias and are being promoted at the expense of the individuals who have lives. This puts a good chunk of employees who are just as likely to be real contributors into a disadvantaged position.
One could also argue that vanilla employees are less likely to be good contributors, especially if their lack of a life correlates with a lack of interest in new things / etc. This is more of a stretch tho.
The trick instead is for those at the top to inculcate a culture where those below are working for good final results directly rather than working to either create an appearance or to satisfy some metric.
If you someone is result-focused, you can relax about the hours they're working.
Is it done? No bugs? Great. Client is happy.
One trick: in weekly 1:1 meetings most employees will start by just discussing their current issues. Instead, start by talking about what you accomplished last week and its value, then move on to what's next. This is still a natural conversation (discussing the past, then future), but it makes your value and results much more visible.