Is the case the kind with a flipcover? If so, then is the flipcover typically folded behind the phone in these situations? A poorly designed case can sometimes have an embedded magnet in the flipcover that is too strong and triggers the smartcover sensor (which puts the screen to sleep) even when the cover is folded behind the phone. Along these lines, also make sure there no strong magnets of any kind on your nightstand.
Does this persist in Safe Mode? https://support.t-mobile.com/docs/DOC-27639
Also, does it happen when the phone is resting on any other surface, or just your nightstand? If it's just your nightstand, then let me harp on the magnets one more time--make sure there are no magnets in the nightstand drawer (if applicable), and that the drawer doesn't use magnets to latch closed.