Spock was acting like a first officer in WNMHGB.
Kirk's never really confided in Scotty like he's the First Officer. From the beginning of TOS Spock has always been in that role of confidant .
Well, true, but only because there were limited opportunities for that sort of Kirk-Scotty interaction. There are actually very few episodes where Kirk and Scotty are present and together, but Spock is missing. But in those few such situations that actually exist, Kirk *does* repose confidence and trust in Scotty. For example:
1. In "Mirror, Mirror," Kirk relies heavily on Scotty while on the I.S.S. Enterprise, including classifying the security research "under my voiceprint or Mr. Scott's."
2. In "City" (even though Spock isn't absent; he's just busy determining when they should jump), Kirk tells Scotty that he, Uhura, and the guards will each have to attempt the same restoration of the timeline if Kirk & Spock fail.
3. In "Spock's Brain" - in yet another of many great little touches that cements the episode in my mind as not merely above the derision it usually receives, but an unsung TOS gem - Scotty immediately and seamlessly slides into the first officer role after Spock is incapacitated. He automatically accompanies Kirk to sickbay, when McCoy calls up after Spock disappears from the bridge, without any orders to do so. For the remainder of the episode, he is a key player in what is essentially Spock's role.
4. Although I am not a great fan of "The Enterprise Incident," there are some good Kirk-Scotty captain-first officer moments once McCoy calls Scotty down to sickbay and reveals the ruse.
Those are just off the top of my head. Another great "Scotty as second officer" moment (albeit with Spock present) occurs in "Wink of an Eye," when the computer gives its recommendation to negotiate with the as-yet-undisclosed Scalosians, Kirk dismisses the idea, then immediately asks Scotty, "You concur?" "Aye."
I'm a relentless Scotty fan and thus perhaps a bit biased, but honestly, the producers' correct recognition that Doohan was fantastic and that Scotty should be the regular third-in-command significantly elevated the overall content of the series in late S1, S2 and S3.