Yeah,derailleur hangers usually take the brunt of the damage. Take a look at the bike from directly behind. The derailleur should be parallel to the frame. If it's angled inwards,then the hanger needs to be replaced. They're usually $15-25.
Note,the scratches may have nothing to do with your shifting issue. It could be the cable just needs adjusting or the chain and/or cassette is worn out. It could also be 'auto-shifting'. Does the rear der cable run under the bottom bracket? If so,try pulling on it on either side of the BB to move the cable back and forth through the tunnel it runs through. Dirt and other gunk can get in there and cause cable drag that can create the issue you're reporting. If that's the case,then the cable just needs some cleaning and lube.
__________________
C'dale BBU('05 and '09)/Super Six/Hooligan8and 3,Kona Dew Deluxe,Novara Buzz/Safari,Surly Big Dummy,Marin Pt Reyes,Giant Defy 1,Schwinn DBX SuperSport,Dahon Speed Pro TT,Brompton S6L/S2E-X