Saint John Vianney then explained to her that the young man was in fact the Devil in human form, and that the only reason why he would not dance with her was because she was wearing the holy Scapular of Our Lady of Mount Carmel."
If the holy Cure had her remember that specific occasion during a general confession he must have considered her desire to dance a sin.
So ... I find this particular episode to be a bit of a stretch, since it's never indicated what the young lady's sin was ... just the desire to dance, or the desire to be chosen, or some desire toward the young man? It's unclear.
He also could have reminded her of it as a didactic lesson, that it CAN lead to sin and to avoid it in the future, since not everything in Confession is just the matter of the Sacrament, as a Confessor will often give spiritual advice for the future. Perhaps St. John Vianney foresaw her getting into trouble in the future on account of a dance, or perhahps the lesson he meant to impart is for her to always wear the Holy Scapular, since perhaps he foresaw an incident where she got into trouble for NOT wearing it.
We just can't read into this particular incident and don't have enough information, despite the author's "he must have considered".
I think there are other incidents that are more clear, where he refused absolution for those who had engaged in dancing. Even then, we'd need to know whether he considered dancing per se to be sinful or if those individuals just happened to sin while they were dancing and the dancing constituted occasion of sin FOR THEM.