This is one of the most beautiful scenes in all of Star Trek. Horrible, but this has always been necessary. At some point, someone has to give an order like this. And in an individual's career, I hope that it doesn't occur, but they absolutely must be prepared to.
BTW, I still maintain Troi never really passed the command test, as presented. Riker gave her the answer. Follow me on this.
He outright tells her "My first duty is to the ship" and that's what clues her in. Is it though? There are times when the ship is placed below the prime directive, or as Picard has occasionally cited, when the truth needs to be exposed, at any cost. (see also The First Duty & The Pegasus) Sometimes the lives of the crew, on the whole, take precedent, like destroying it, after evacuating, to prevent it falling into enemy hands, etc... So the ship is not always duty #1 & we all know that.
So, then what Riker meant was "my 1st duty (in this specific situation) is to the ship's well being". He's basically telling her to prioritize saving the ship over any one life... in her scenario, by thinly veiling it as relevant to his own command duty about letting her serve there. It's a *wink wink* "Here's what you're not figuring out"
But if this is truly not a test of technological understanding, but ultimately is one of testing character, and a capability to choose death for people, then she never organically arrived at that solution. It was not (or not yet) within her nature to arrive at that solution naturally. She had to have someone else frame it that way 1st. There are multitudes of other different situations, that might put her in that place, and if she isn't the sort to make that call instinctively or intuitively, (or isn't yet) she's still just as susceptible & fallible as she was, on those other bunch of times she failed to save the ship, during the test.
She hasn't independently demonstrated that she has the individual capacity to arrive at that hard choice, when it presents itself as the only solution, and in future crises, she may fail to do so, unless there's someone who can remind her or has the luxury of time to frame it as her only option. She DID demonstrate that she knows how to spend ages pouring over every permutation for a very long time, & still not make the connection, on her own.
She just figured out (thru Riker's hint) that the fix was that you have to kill holo-Geordi, & then she did that, with a bunch of attitude, like "oh... this BS, about judging what kind of personality I have". Yeah! Exactly that. Some people are innately capable of that. Some people are fundamentally incapable of getting to that place ever, and some people only get to it thru major introspection about what kind of person they are. She didn't exhibit ANY of that. So which is she? And until then, is she competent?
I think Riker gave her a pass,
because of her history in
Disaster, where she already came up against tough choices, but that's still sketchy imho, because her solution in
Disaster was to risk everybody to save some of the crew, which is kind of the opposite inclination, and she admits herself that she put everyone right up against losing the whole ship over it.
I always understood Star Trek to work on the idea that a higher-ranking officer can automatically give orders to anyone of lower rank. The only exceptions would be if the lower-ranking officer was already following orders from someone even higher up, or if their area of expertise overrode the chain of command. For example, Crusher could relieve even Picard of command if necessary. And by the same logic, if there were a dangerous situation where Worf had the most relevant expertise, he could probably give an order to a higher-ranking officer—something like, “Get out of here, it’s not safe.”
Expertise doesn't really override rank. A Doctor's orders can't supercede a higher ranking officer's, unless they are declaring them medically unfit to serve, which removes them from the chain of command entirely, in which case they can no longer give any orders. That's not quite the same thing.
I'm pretty sure the only one that can do anything like your last example, is a 1st officer countermanding their captain's orders, on the grounds that they're unduly putting
themselves in harm's way, & even that one is open to a lot of different interpretations.
Really, the only time it seems universally acceptable that a lower ranking officer has authority over higher ones, is when an even higher ranking one has explicitly given them authority to do so, which one could argue is the case in the previous example. Highest command allows 1st officers to interfere in a captain's authority, in the one scenario where they are endangered.
I suppose you could try to extend that to any officer, that is next in line below a captain, doing the same to protect them, but that's going to be pretty iffy, depending on the officer. Otherwise, lower ranking officers have no place ordering around higher ranking ones.