In a heavy cast-iron Dutch oven, cook the bacon over medium-high heat until the fat has rendered and the bacon is crisp, 4 to 6 minutes. Add the onion and cook, stirring, until it is softened and lightly caramelized, 3 to 4 minutes. Add the garlic and thyme, and cook for 1 minute longer. Then add the beans, coffee, barbecue sauce, brown sugar, mustard, molasses, hot sauce, and pepper, and stir to combine well. Add the water and salt, raise the heat, and bring to a boil. Cover the pot, transfer it to the oven, and bake for 2 hours, undisturbed.
Remove the pot from the oven, and stir the beans. Re-cover the pot and continue to bake until the beans are tender, about 1 hour longer.
When the beans are tender, remove the cover from the pot and continue baking until the liquid has reduced to a thick, saucelike consistency and the beans are thick and flavorful, 1 to 1 1/4 hours. Remove the pot from the oven, and remove the thyme sprigs. Adjust the seasoning if necessary, and serve the beans either hot or warm.