(Warning: this is a rant)
Is the right thing to do a matter of the act itself, or the consequence of the act? This is an old philosophical question based on an obsolete understanding of human behavior. To frickin wit: the brain simulates outcomes when triggering actions. All actions imply a consideration of consequences. As noted in prior posts, the brain is a prediction machine. The brain spurs the body (including its communication features) to act according a hierarchy of goals (desired outcomes), constantly updating action and subgoal as errors are corrected and goals adjusted.
Even when we think we're doing the right thing as an "end-in-itself", there is an implicit assumption that the world will turn out better (at least in the "long term") if we simply focused on the action itself, consequences be damned. Basically, it's a heuristic that resolves a lot of ethical dilemmas. We need heuristics because life is complicated; we can't think through everything.
And that's fine. Everyone needs mental shortcuts. But mental shortcuts are not to be mistaken for philosophy.