There are actually two switches on the brake pedal, but you're correct in assessing that if the brake lights work then the switch is good, because the AT interlock is triggered by the same switch. The other switch is for the cruise control system.
The likely culprit is the park position switch on the back of the shifter assembly. When the shifter is in the Park position, it closes the ground leg of the shifter solenoid that unlocks the shifter when the brake pedal is pressed. If you supply 12V to the solenoid (also on the shifter assembly) and it latches, then the solenoid is good. You can check for continuity on the switch.
In my case, my truck's previous owner tucked a chunk of tubing into the shifter override (the hole you can stick a screwdriver in to manually get the shifter out of park) because the park switch had failed. I found a replacement switch on Digikey (.com) for a couple bucks and soldered it in. You can use the tubing approach in a pinch, being fully aware that it will allow the truck to be shifted out of Park without a key and without the brake pedal being depressed. I'd just keep a screwdriver or tool in the truck until it's fixed.
Don't forget there's also an interlock cable that provides mechanical functionality. The shifter moving from park also requires a key in the ignition and turned to ON. It's unlikely it's the problem, but you'd want to confirm that the correct slack/length is set where the cable connects to the shifter assembly.
Full details are in the Factory Service Manual: https://www.nicoclub.com/nissan-service-manuals. Check the Automatic Transmission (AT) chapter, "A/T SHIFT LOCK SYSTEM" section after all the diagnostic code stuff.