Soak the beans (if using dried): Cover beans with plenty of water and soak 8–12 hours, then drain and rinse.
For a quick soak, boil beans for 2 minutes, turn off heat, cover, and let sit 1 hour. Drain and rinse.
Sauté the aromatics: In a large heavy pot, warm the olive oil or butter over medium heat. Add onion, carrot, and celery with a pinch of salt.
Cook 5–7 minutes until softened. Stir in garlic for 30 seconds.
Build the base: Add bay leaves and thyme. Nestle in the ham bone or ham hocks.
Pour in 6 cups of broth or water to start. If using canned beans, wait to add them later.
Cook the beans: If using dried beans, add them now. Bring to a simmer, then reduce heat to low.
Cover partially and cook gently until beans are tender, about 1.5–2 hours. Stir occasionally and add more liquid as needed to keep everything submerged.
Shred the ham: When beans are tender, remove the bone or hocks. Pull off and shred any meat.
Discard skin, gristle, and bay leaves. Return shredded ham to the pot.
If using canned beans: Add them now. Simmer 20–30 minutes to meld flavors and slightly thicken the broth.
Adjust texture: For a creamier soup, mash a cup of beans against the side of the pot or use an immersion blender for a few short pulses.
Add extra broth if it gets too thick.
Season smartly: Taste before salting, since ham can be salty. Add salt and plenty of black pepper. A splash of apple cider vinegar brightens the flavor at the end.
Serve: Ladle into bowls and finish with parsley or a pinch of red pepper flakes.
Good with crusty bread or cornbread.