Śrīmad-Bhāgavatam · Text 3.23.55
Who is speaking and story frame
सङ्गो य: संसृतेर्हेतुरसत्सु विहितोऽधिया ।
स एव साधुषु कृतो नि:सङ्गत्वाय कल्पते ॥ ५५ ॥
saṅgo yaḥ saṁsṛter hetur
asatsu vihito ’dhiyā
sa eva sādhuṣu kṛto
niḥsaṅgatvāya kalpate
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.
Read Śrīla Prabhupāda's purport on Vedabase.io