There are bits in the law about management having a fiduciary duty to shareholders, but that mainly means that they aren't supposed to be stuffing their own pockets at the expense of investors. There's a wide birth for management to decide what kinds of profit are and are not worth it.
This change may even depress the stock price directly as disgusted owners sell (this harms the ability of current shareholders to earn a return, as the loss is now but the future revenues are discounted).
The market is as moral as its shareholders, which is far less than perfection but a lot better than zero.
The case in question is Dodge vs. Ford and rather than believe memes about it just read the darn wikipedia page: https://en.wikipedia.org/wiki/Dodge_v._Ford_Motor_Co.
I'm all for pointing someone to the sources, but let's not instill the idea that consulting Wikipedia is doing substantially more diligent research than looking at memes.