One verse

Srimad Bhagavatam 3.23.55

3.23.55

सङ्गो य: संसृतेर्हेतुरसत्सु विहितोऽधिया । स एव साधुषु कृतो नि:सङ्गत्वाय कल्पते ॥ ५५ ॥

sango yah samsrter hetur asatsu vihito ’dhiya sa eva sadhusu krto nihsangatvaya kalpate

sangah
association
yah
which
samsrteh
of the cycle of birth and death
hetuh
the cause
asatsu
with those engaged in sense gratification
vihitah
done
adhiya
through ignorance
sah
the same thing
eva
certainly
sadhusu
with saintly persons
krtah
performed
nihsangatvaya
to liberation
kalpate
leads.

Association for sense gratification is certainly the path of bondage. But the same type of association, performed with a saintly person, leads to the path of liberation, even if performed without knowledge.