Following the panned Hank Azaria vehicle Imagine That – where both he and Azaria were described as "talent going to waste" – Malina played Will Bailey on The West Wing from 2002 to 2006. His character initially was perceived by the public as an attempt to replace departing series star Rob Lowe, although Malina said in numerous interviews that the two actors and characters were too dissimilar to be viewed as anything but a change. During his tenure on The West Wing, Malina was known to the rest of the cast as a tireless prankster. It is said he coated telephones with Vaseline and reset Producer Alex Graves's iPod menus to Mandarin Chinese. He stole some of Bradley Whitford's letterhead stationery and used it in an elaborate prank. At the suggestion of co-star Janel Moloney, Malina sent a $200 Valentine's Day bouquet to season-six newcomer Jimmy Smits that included a card crafted on Whitford's stolen letterhead stating: "Jimmy, You are a delight. I enjoyed every moment we've had together. Be my Valentine." Following the end of The West Wing, Malina campaigned for the leading role of Danny Tripp in Sorkin's next TV project, Studio 60 On the Sunset Strip, but the role went instead to Whitford. When the show was cancelled in its first season, Malina was teased by some in the industry who suggested he was Sorkin's good luck charm, but he pointed to Sorkin's upcoming film Charlie Wilson's War as evidence his friend could succeed without him.