The Buddha describes four cases of deeds, and how an immature person and a wise person are to be understood by their responses to deeds that are disagreeable but lead to benefit and deeds that are agreeable but lead to harm.
Ṭhāna sutta - Cases Of Deeds
"Bhikkhus, there are these four cases of deeds. What four?
There is a deed that is disagreeable to do, and doing it leads to harm. There is a case where a deed is disagreeable to do, and doing it leads to benefit. There is a case where a deed is agreeable to do, and doing it leads to harm. There is a case where a deed is agreeable to do, and doing it leads to benefit.
1 Here, bhikkhus, consider a deed that is disagreeable to do, and doing it leads to harm—such a deed, bhikkhus, is regarded as not to be done on both grounds. In the case of a deed that is disagreeable to do, it is considered not to be done for this reason as well. In the case of a deed that, when done, leads to harm, it is considered not to be done for this reason as well. Such a deed, bhikkhus, is regarded as not to be done on both grounds.
2 Here, bhikkhus, consider a deed that is disagreeable to do, but doing it leads to benefit. In this case, bhikkhus, an immature person and a wise person are to be understood by their resilience, energy, and continued effort. The immature person, bhikkhus, does not reflect thus: 'Although this deed is disagreeable to do, when done, it leads to benefit.' Therefore, they do not do that deed, and refraining from it proves harmful. But the wise person, bhikkhus, reflects thus: 'Although this deed is disagreeable to do, when done, it leads to benefit.' Therefore, they do that deed, and doing it leads to benefit.
3 Here, bhikkhus, consider a deed that is agreeable to do, but doing it leads to harm. In this case, bhikkhus, an immature person and a wise person are to be understood by their resilience, energy, and continued effort. The immature person, bhikkhus, does not reflect thus: 'Although this deed is agreeable to do, when done, it leads to harm.' Therefore, they do that deed, and doing it leads to harm. But the wise person, bhikkhus, reflects thus: 'Although this deed is agreeable to do, when done, it leads to harm.' Therefore, they do not do that deed, and refraining from it proves beneficial.
4 Here, bhikkhus, consider a deed that is agreeable to do, and doing it leads to benefit—such a deed, bhikkhus, is regarded as to be done on both grounds. In the case of a deed that is agreeable to do, it is considered to be done for this reason as well; and in the case of a deed that, when done, leads to benefit, it is considered to be done for this reason as well. Such a deed, bhikkhus, is regarded to be done on both grounds.
These, bhikkhus, are the four cases of deeds."