Best case: Scotty beaming down to build a hardware patch for the pergium reactor in "Devil in the Dark."
Also worst case: what's the level of Scotty's incompetence if he can't get a simple pump right? Basically, those ought to be black boxes, with input and output specs. Is a pergium reactor perhaps especially corrosive in terms of what gets pumped? Or cooled by liquid sodium or whatever? Why would the patch fail in a matter of days otherwise?
Worst case: Spock and McCoy (!) modifying photon torpedo hardware in Star Trek VI. It was hugely obvious that they were giving Kelley a scene rather than keeping his character in plausible activities.
OTOH, just as with the final beam-down where the main heroes get to stop the assassination all on their own even though Kirk's ship is stocked with competent redshirts, it's also a case of the usual specialists being fundamentally untrustworthy. Scotty is up to his elbows in combat repairs; if Spock asks him to send his trusted lieutenant Gabler up to help with the torp, this potential traitor may well blow up the whole starship.
"Doing what the enemy can't possibly expect" is a great excuse for all sorts of plot idiocy... Especially in Trek, where the enemies are exceptionally imaginative and/or omniscient, and the range of potential actions available to our heroes is nothing short of infinite or absurd.
Timo Saloniemi