Prepare the Pinto Beans (if using dried): Soak the pinto beans overnight or for at least 6 hours to reduce cooking time. If using canned beans, drain and rinse them before adding to the soup.
Cook the Vegetables: In a large pot or Dutch oven, heat the olive oil over medium heat. Add the diced onion, carrots, and celery. Sauté for about 5-7 minutes until softened. Add the garlic and cook for another minute until fragrant.
Add the Ham and Liquid: Stir in the cubed ham, followed by the soaked pinto beans (or canned beans), and chicken broth. Bring the soup to a boil.
Simmer: Reduce the heat to low and let the soup simmer for 1 to 1.5 hours (or until the beans are soft). If using canned beans, reduce the cooking time to 30-45 minutes. Add the thyme, bay leaves, black pepper, and salt. Taste and adjust seasonings as necessary.
Optional Greens: About 15 minutes before the soup is done, stir in chopped spinach or kale for added nutrition and color.
Finish and Serve: Once the soup is ready, remove the bay leaves. Ladle the soup into bowls and serve hot. You can garnish with fresh herbs or a squeeze of lemon juice for extra flavor.