Start by sorting through the dried pinto beans and removing any debris or damaged beans. Rinse them thoroughly under cold water.
Place the beans in a large bowl and cover with water. Let them soak overnight, or for at least 8 hours. This helps them cook evenly and reduces cooking time.
Drain and rinse the beans once more.
In a large pot or Dutch oven, heat the oil over medium heat. Add the chopped onion and cook for about 4–5 minutes until soft and translucent. If using garlic, add it now and cook for 30 seconds until fragrant.
Add the soaked beans to the pot, followed by the water. Stir gently and bring everything to a boil.
Once boiling, reduce the heat to low and let the beans simmer uncovered. Add the ham hock or bacon if using.
Cook for 2½ to 3 hours, stirring occasionally. As the beans cook, they’ll soften and the broth will thicken slightly. Add more water if needed to keep the beans submerged.
About halfway through cooking, season with salt, pepper, and sugar if using. Taste and adjust seasoning near the end.
Once the beans are tender and creamy, remove the ham hock, shred any meat, and return it to the pot. Serve warm.