As long as they are not egregiously and obviously acting against that goal, or taking decisions without deliberation, the law would favor them in any trial that only hinged on whether the price offered by Musk was better than the market. Basically the burden of proof to show that it could not have been a good business decision would lie with the plaintiff, and I very much doubt that you could build a solid case of that.
On the other hand, the board can easily say "we don't beleive this deal offered by a person who isn't allowed to be a public officer of a company anymore will ever go through, either because he will retract it or because he will be unable to secure funding; and we beleive attempting the deal will hurt stock prices and profits for current shareholders" and then I agree, it would probably be a slam dunk in court.
All of this would need to be litigated on a case-by-case basis, but many modern cases have found that companies can freely act to maximize the wages of their employees at the expense of dividends or act charitably even when there aren't tax breaks.
That said, I'm not sure this really even applies in the case of Twitter---I think its not unreasonable to argue that the innate value of Twitter is so much higher than what Musk is offering that its better for the shareholders to wait even thinking purely in terms of profits (I would probably personally disagree with that, but I don't think its any more unreasonable than plenty of other valuations I see)