Publicly traded companies are legally bound to prioritize shareholder demands ahead of any other duties.
This is actually a myth. They are expected to be responsible with their money, but they are not in any way required to maximize profit from a legal perspective. They repeat the lie because it is a good excuse to be evil. If a company doesn't do what it's shareholders like, they may vote out the board, or they might sue if the prospective was fraudulent (said they were working on something that they weren't for example... But remember also that American companies don't make forward statements like European ones do, so those cases are going to be things like "last year we spent 10 million on R&D" when they actually spent the money on plane trips to cocaine parties) but those are the recourses available to shareholders.