They do check to see if you've had any involuntary commitments to mental hospitals during the NICS background check, but whether or not you would actually show up on one of those lists is a whole other issue that's dependent on like ten other variables (the exact nature of your commitment, the state where it happened, the state where you're purchasing the gun etc). There's no federal law requiring states to report mental health records so it's kind of a crapshoot with states and individual hospitals just doin their own thing. NY is pretty strict though so if your black mark on your mental health records originated in this state then I would think they would catch that on a background check.
Research New York state laws on mental health reporting, including what is regulated and what's not. Find related gun law details from Giffords Law Center to Prevent Gun Violence today.
lawcenter.giffords.org
Feel free to PM me once you get those privileges if you want to chat more about your particular background check situation