James 4:17

17 If anyone, then, knows the good they ought to do and doesn’t do it, it is sin for them.

Read James 4:17 Using Other Translations

Therefore to him that knoweth to do good, and doeth it not, to him it is sin.
So whoever knows the right thing to do and fails to do it, for him it is sin.
Remember, it is sin to know what you ought to do and then not do it.