The legal terminology for that is “mens rea” literally “guilty mind” https://en.wikipedia.org/wiki/Mens_rea