 Meanwhile , Pam Beesly ( Jenna Fischer ) finds a screenplay written by Michael called Threat @-@ Level Midnight starring himself as " Agent Michael Scarn " , and the staff read it together . While reading the script , the character sequence " Dwigt " appears . Pam explains to the camera that originally , Michael based his incompetent sidekick on Dwight Schrute ( Rainn Wilson ) , but later changed the name with a search and replace . Unfortunately , the search and replace mechanism failed to change Dwight 's misspelled name . Dwight is upset and quickly shuts down the exercise to invite everyone to set off fireworks outside , but only Kevin Malone ( Brian Baumgartner ) follows . 
