Preheat oven to 400 degrees. Grease the bottom and sides of a square glass baking dish.
Put the oil in a large skillet over medium heat. When oil is hot add the shallot and onion, cooking until soft, about 5 minutes. Add the thyme and cook for another minute. Add tomatillos and stock to the skillet, cooking while stirring occasionally until tomatillos break up and become saucy, about 10 minutes.
Put half the beans in the bottom of the greased dish, sprinkling with salt and pepper. Follow with a layer of the tomatillo mixture, then a layer of the shredded chicken, finally a layer of cheese. Repeat with the other half of the ingredients to make a second layer to the dish. Bake until the casserole is hot and the cheese is bubbly, 20 to 30 minutes.