Hazrat Shaikh Moulana Muhammad Zakariyya (rahmatullahi ‘alaih) once mentioned the following:
One should not say or do anything wrong in the presence of children as this will have a negative impact on them. The Mashaayikh mention that even if an evil action is done before a young child who is not of the age of understanding, then too it is possible that the evil effects of the sin carried out in the presence of the child who sees it or hears it can be captured by the mind of the child. Thereafter, this wrong can surface at some point during the life of the child.
(Qutbul Aqtaab Hazrat Sheikhul Hadith Moulana Muhammad Zakariyya (rahmatullahi ‘alaih) pg. 560)