Prep the oven and baking pan. Position a rack in the center of the oven and preheat the oven to 350°F. Line 2 to 3 half sheet pans with parchment paper.
Mix the dry ingredients. In a small bowl, whisk together the flour, baking powder, baking soda, and salt.
Mix the butter, sugars, egg, and extract. In a medium bowl, use a rubber spatula to mix together the butter and sugars until moistened, about 1 minute. Add the egg and vanilla extract and mix until combined. Add the dry ingredients, chocolate and M&Ms. Gradually mix in the dry ingredients until just combined. Add the chocolate and M&Ms all at once and mix until the chocolate and candy are evenly distributed throughout, about 1 minute.
Assemble the cookies. Use a 3-Tablespoon cookie dough scoop to portion the cookie dough into balls, placing them at least 3 inches apart on the prepared sheet pans as you go. Gently press 5 to 6 more M&Ms on top of each cookie dough ball. Bake the cookies. Bake one pan at a time for 10 minutes, or until the edges have set but the centers are still gooey. Garnish immediately with flaky salt and mini M&Ms, if using. Cool the cookies on the pan on a wire rack for 20 minutes, or until the edges and bottoms of the cookies have set and feel firm to the touch. Repeat with the remaining cookie dough. Serve and store. Serve warm or at room temperature. The cookies can be stored in an airtight container or zip-top bag at room temperature for up to 3 days.