Take a look at the original sentence again:
Nathalia likes to get good grades but hates when her friends call her a
nerd, sometimes Nathalia will claim that
she got a 77 on a test when, in reality, she earned a 97.
You chose to fix it the correct way:
Nathalia likes to get good grades but hates when her friends call her a
nerd, so sometimes Nathalia will claim that
she got a 77 on a test when, in reality, she earned a 97.
Connecting two complete sentences with a comma and a coordinating conjunction like so is perfectly legal in writing. Nathalia likes to get good grades ... begins the first complete sentence. Sometimes Nathalia will claim ... starts the second complete sentence. The comma and so legally connect the two sentences while correctly showing the cause-and-effect relationship.