the initial pronoun, the subject you can treat not just as ты, but ты сам, you yourself
and so both are declined

in the translated version it may look as 'With whom were you cheating on your own self?'

С кем себе самому изменял technically can exist without the declined сам just fine, сам only makes the sentence more complete

so any pronoun in reflexive is declined as себя/себе/собой etc, but can also take the form of себя самого/себе самому/собой самим etc or сам себя/сам себе/сам собой etc