According to the Cambridge Dictionary
to succeed in doing or dealing with something, especially something difficult
[ + to infinitive ] Did you manage to get any bread?
In your sentence manage applies to an infinitive: scrape
to succeed in getting or achieving something, but with difficulty or
by a very small amount
What's that something achieved by Harry and Ron? Passes
had managed to scrape passes - [verb] + to + infinitive + object.
@Tᴚoɯɐuo has pointed that this verb is intransitive but is being used transitively here, which is unusual, at least to my AmE ear. This might be a BrE slang usage
According to the Oxford Dictionary
A success in an examination, test, or course.
The whole sentence means that they passed the exams but with low qualifications. Notice what I highlighted above: by a very small amount.