Place beans in a colander and rinse them well with cold water and allow to drain. Pick through the beans and remove and discard any debris.
Add oil to the Instant Pot and press the SAUTE button. When display reads "Hot" add the onion, carrot, and celery. Cook, stirring, for 4 to 5 minutes, or until onion and veggies begin to soften. Add garlic and cook for an additional minute then press CANCEL.
Add beans, broth, water, tomato sauce, chili powder, cumin, oregano, cayenne, and the bay leaves. Stir well to combine. Tuck the ham shank (or meaty ham bone) down into the mixture. Lock the lid in place and make sure vent is sealed (on older models). Press the MANUAL or the PRESSURE COOK button, select HIGH, and cook for 40 minutes.
When time is up, allow the steam pressure to naturally release for 15 minutes then manually release any remaining pressure. Unlock and remove the lid. Transfer ham shank (or bone) to a cutting board. Use a fork to remove the ham from the bone and stir it into the soup. Discard the bone.
If a creamier (less brothy) texture is desired, pulse the mixture with an immersion blender 3 or 4 times, just to break up some of the beans. Don't go overboard, you want lots of whole beans and a few pulses will yield a nice and creamy result.
This soup is excellent reheated. It will thicken when refrigerated so just add a little water to reach desired consistency.
Taste and season with salt and additional pepper, if desired. I don't recommend adding any salt until the end of the cooking process as the seasoning ham, tomato sauce, and broth tend to add enough.