Any good faith business decision counts as a move meant to benefit shareholders, especially where there are tradeoffs involved. If you make user experience worse to boost advertising revenues, you can argue that was the right call because you get more money. If you make your user experience better in a way that hurts advertising revenues, you can argue that it was the right call because it improves user loyalty and user perception of Facebook, making it more valuable in the long run. Even if it turns out that your decision was wrong, it's an honest mistake and you're allowed to make those. There's no way shareholders could ever win a lawsuit by second-guessing business decisions they disagree with! About the only thing you can't do is outright embezzle money from the company or something.
Now, for a public company, lots of investors base their decisions on the GAAP numbers companies are forced to report, so there are incentives to improve those numbers each quarter if you want to boost stock price. But if you communicate a long-term strategy to investors and seem competent enough to pull it off, you're Amazon and your stock price does well anyway, even if you lose money.