You shouldn't have to tear out the carpet and headliner to see if that's it. It's usually clogged in the top by dirt.
PArk the car with the front of the car lower than the rear. open the sunroof. use a cup of water and pour it into the track. The drain holes are at each corner and should drain freely out each, and you'll see the water exit under the vehicle. Then repeat for the rear.
If it's clogged up, generally it's just a leaf or stick or something at the top. you can remove it and all is well. Sometimes you have to blow some compressed air into the hole to dislodge whatever dirt has accumulated in there. That tray around the edge of it is to catch the water and channel it to those drain holes. When one (or more) are clogged, then essentially the tray will overflow, and the water will pour into the headliner, down the pillar and collect on the floor.
IF the drains are clear, there's a chance the hose has come disconnected from the sunroof tray. in which case, now is the time you'll have to pull the headliner. not terribly difficult, but not a fun job.
You WILL want to still pull out all the carpet regardless if it's that wet. Take it outside and set it upside down on a couple sawhorses or something in the sun for a day to dry out. once it is dry, spray it real good with bleach. Spray the metal flooring of the car real heavy with bleach as well. let that all dry out real well before you reassemble.