There are a lot of dubiously sourced webpages claiming Padre Pio said this and that. At this point, I take them with a grain of salt.
Anything purporting to describe Padre Pio saying something in confession clearly didn’t come from Padre Pio due to the seal of the confessional. It would likely have either come from the person who made the confession, who may have also left out a number of important details, or it could just be a made-up story or hearsay attributed to Padre Pio.
Padre Pio had a gift from God of reading hearts. He could tell if someone had simply forgotten some sin or was hiding some sin. Even assuming this happened, it sounds like the disco was an occasion of sin for the man who went there, who presumably was indulging in things like excessive drink and/or lust when he went.
The Catholic Church does NOT teach that dancing in general is a sin or that discos in general are sinful. Some dancing is meant to be sexually arousing or suggestive, like twerking or “gentleman’s club” dancing or “dirty” dancing, and obviously those dances are sinful. Some discos also have sinful activities regularly happening there like sex, prostitution, drug use, excessive drinking, sinful forms of dancing, immodestly dressed patrons, sexual assault etc. and obviously it can be sinful or a near occasion of sin for people to visit them.