Sort the dried beans on a baking sheet, discarding stones or shriveled beans, then rinse in a colander. Cover with at least 2 inches of cold water and soak at room temperature for 8 to 12 hours or overnight, then drain and rinse.
Dice the onion into 1/2-inch pieces, slice the carrots into 1/4-inch rounds, dice the celery to match the onion, and mince the garlic. Dice the cooked ham into bite-size cubes and refrigerate until needed.
Heat the olive oil in a Dutch oven over medium heat. Add the onion, carrots, and celery and cook 6 to 8 minutes until the onion is soft and translucent, then add the garlic and cook 30 to 60 seconds until fragrant without browning.
Stir the drained beans into the pot and nestle in the ham hocks. Pour in the broth and water, add the bay leaves, thyme, black pepper, and red pepper flakes if using, and stir once—do not add salt yet. The liquid should cover the beans by about an inch.
Bring to a boil over high heat, about 10 minutes, then reduce to low for a gentle simmer. Skim off any foam, partially cover, and simmer 1 1/2 to 2 hours, stirring every 20 to 30 minutes and adding hot water if the liquid drops below the beans. Beans are done when completely tender and creamy at 1 1/2 hours.
Lift the ham hocks out with tongs, cool 5 to 10 minutes, then pull off the meat with two forks, discarding skin, bones, and large fat pieces. Chop the meat, discard the bay leaves, and return the shredded meat and diced ham to the pot.
Mash about 1 cup of beans with a little broth until mostly smooth and stir back in, or pulse 3 to 4 times with an immersion blender. Simmer uncovered 15 to 20 minutes until creamy and brothy, adding hot water if too thick.
Taste and add kosher salt a little at a time, stirring and tasting after each pinch. Add more black pepper or red pepper flakes if desired, ladle into bowls, sprinkle with fresh parsley, and serve hot.