Preheat oven to 375°F (190°C).
In a skillet, heat olive oil and sauté onions and garlic until soft.
Add ground beef and cook until browned. Drain excess fat.
Stir in baked beans and season with salt and pepper.
In a greased baking dish, layer half the potato slices, followed by the beef mixture.
Spread cream of mushroom soup over the beef mixture and add remaining potato slices on top.
Cover with foil and bake for 45 minutes.
Remove foil, sprinkle with cheddar cheese, and bake for another 15 minutes until golden and bubbly.
Let it rest a few minutes before serving.