Heat the olive oil in a large skillet over medium heat.
Stir in the garlic, shallots, and red pepper flakes until the garlic is fragrant but not browned, about 3 minutes.
Add the spinach and mushrooms and stir until the spinach is wilted.
Stir in the walnuts and cook until the nuts give off a toasted smell, about 2 minutes.
Stir in the sliced ham and cook the mixture until the ham is hot and beginning to brown, about 5 more minutes.