Pour the dried navy beans onto a rimmed baking sheet, pick out any stones, debris, or shriveled beans, then transfer to a fine mesh strainer and rinse under cold running water for about 30 seconds. Set aside to drain.
Dice the onion into 1/4-inch pieces, peel and small-dice the carrots, slice and chop the celery, mince the garlic, and cut the cooked ham into 1/2-inch cubes.
Press Sauté on the Instant Pot and heat for about 2 minutes, then add the olive oil, onion, carrots, and celery. Cook for 5 to 6 minutes, stirring often, until the onion turns translucent and the vegetables soften.
Stir in the garlic and cook for 30 seconds until fragrant, add the diced ham and cook 2 to 3 minutes until the edges color, then stir in the thyme, black pepper, and red pepper flakes for 30 seconds. Press Cancel.
Pour in 1 cup of the broth and scrape the bottom of the pot well, then add the rinsed beans, remaining 6 cups broth, and bay leaves. Nestle in the ham bone or ham hock if using, stir gently, and do not add salt yet.
Close and lock the lid, set the valve to Sealing, press Pressure Cook (or Manual) on High, and set the timer for 35 minutes. Allow about 10 to 15 minutes for the pot to come to pressure.
When the timer ends, press Cancel and let the pressure release naturally for 15 minutes, then carefully turn the valve to Venting to release any remaining steam. Wait until the float valve drops before opening the lid, tilting it away from you.
Remove the bay leaves and ham bone or hock, pulling off and chopping any meat to stir back in. Taste the beans for tenderness, season with salt as needed, and mash a few beans against the pot or pulse with an immersion blender for a thicker broth. Ladle into bowls and garnish with parsley.