For example "You saved me the trouble by keeping my badge". How can I express the same sentiment in French?
Would this be a good solution?
Vous m’avez fait économiser le problème par garder mon badge.
If the meaning is “If you hadn't kept my badge, then I would have had some trouble” (which I would express in English with “You saved me some trouble by keeping my badge”) — for example, if you hadn't kept my badge, then I would have had to pay and spend some time to renew it — then in French, I would use the word ennui. In this sense, ennui is not related to boredom, it means difficulties, trouble. Ennui is more idiomatic than problème or difficulté when the nature of the problem(s) is not specified, especially when there are multiple problems.
Vous m'avez évité des ennuis en gardant mon badge.
If the meaning of “trouble” here is a small extra burden (“If you hadn't kept my badge, I would have had to spend five minutes getting a new one”), then ennui isn't the right word. You can say
Vous m'avez épargné une corvée.
(You saved me from a chore.)
Économiser is not a good fit here. It can be a translation of save in a financial context, and it can be used with words such as effort, but not with trouble.
"Vous m'avez épargné la peine de perdre mon badge."
It seems to me the more casual translation. The idiom "s'épargner la peine de ..." is usually followed by some kind of long task ("peine" taking in this context the meaning of "effort", not "douleur") but it can also, like here, refer to something just frustrating, disappointing or sad.
I hope the following will not be seen as an offense but I must say the first translation, at the bottom of the OP, looks just like plain, untouched google-bred. Is it not ?