So I was analyzing my Sun save and I realized that one of the Pokémon I did all the 6th generation contests with was being flagged as illegal. I decided to look into my save backups and found a backup before any contests were done and another one after that. After the contests, orginal OT affection went from 0 to 140. All the backups I found after that point show its value back to 0 because probably due to trading with PKHeX between games. Did older versions reset the mentioned value to 0 when trading from one save to the other?
The first picture is from the original save, without the contests done. The second one is after the contests had been done. The third one is when it was traded (using PKHeX) from the Alpha Sapphire save to an Omega Ruby save (that has the same OT).