If after I said it won't work, the player tells me he hides under the table anyway, it will autofail regardless of stealth skill. As for the door, the player will get a roll, but if someone walks into the room he's probably automatically going to be seen. You can't hide while in plain view of someone. If on the other hand the NPC just peeks his head into the room and scans, there's a good chance that the one behind the door will get away with it.
Yes, if the DM prompts the player that their action won't be successful and the player takes it anyway? Not much to say about that.
But if the DM asks for a declaration, the player makes it and then the DM declares it an autofail (because HE thought it was clearly not a smart move) - I have a problem with that. The DM clearly thought the situation was well outlined to the players but obviously it wasn't because players generally do not pick autfailing actions.
So, hopefully, if the stakes/conditions are properly outlined and the DM is acting in good faith - this doesn't happen. That make sense?