Rinse the rice in a fine-mesh strainer under cool water until the water runs mostly clear. Let it drain well.
Heat the oil in a medium heavy-bottomed pot or Dutch oven over medium heat. Add the white parts of the scallions and the garlic. Cook, stirring often, for about 1 minute, just until fragrant.
Stir in the thyme, allspice, salt, and black pepper. Add the coconut milk, broth, kidney beans, drained rice, and the whole Scotch bonnet or habanero, if using. Stir gently once to combine.
Bring the liquid to a gentle boil over medium-high heat. Once boiling, reduce the heat to low, cover tightly, and cook for 18 to 22 minutes, until the rice is tender and most of the liquid is absorbed. Avoid lifting the lid while the rice cooks.
Remove the pot from the heat and leave it covered for 10 minutes. Remove and discard the whole pepper. Fluff the rice gently with a fork, then fold in the green parts of the scallions. Taste and add a small pinch of salt if needed.
Serve warm as a side dish with grilled chicken, fish, jerk-style dishes, stews, or roasted vegetables.