Reuben Foster

San Francisco 49ers draft pick Reuben Foster answers questions at a press conference in Santa Clara, Calif., on Friday, April 28, 2017.

(AP Photo)

The San Francisco 49ers had Alabama linebacker Reuben Foster as the No. 3 player on their draft board. San Francisco coach Kyle Shanahan called Foster "my favorite player in this draft." Yet the 49ers were able to get him with the No. 31 pick in the 2017 NFL Draft on Thursday night.

How that happened is detailed by Sports Illustrated's Peter King in his Monday entry of "Monday Morning Quarterback." King spent the draft in the 49ers' "war room."

The top three draft targets for San Francisco were Texas A&M defensive end Myles Garrett, Stanford defensive end Solomon Thomas and Foster, in that order.

The 49ers held the second pick, and they had an agreement in place to swap spots with the Chicago Bears at No. 3, if the Cleveland Browns took Garrett at No. 1. The Browns did, and the 49ers and Bears traded first-round picks, with San Francisco also picking up third- and a fourth-round choices this year and a 2018 third-rounder in the deal, without knowing which player Chicago would select.

The Bears stunned draft watchers by taking North Carolina quarterback Mitchell Trubinsky.

Ready to pick Foster at No. 3, the 49ers instead got their No. 2 player, Thomas, with the No. 3 pick.

"Had Solomon been gone, we'd have gone Reuben and been happy," King reported San Francisco general manager John Lynch told him.

Now how to get Foster, too?

Lynch didn't think Foster would slip past the Cincinnati Bengals at No. 9. But the Bengals picked Washington wide receiver John Ross.

Shanahan didn't think Foster would slip past the Baltimore Ravens at No. 16. But the Ravens, whose general manager is former Alabama star Ozzie Newsome, took another Crimson Tide standout, cornerback Marlon Humphrey.

As picks kept coming off the board, the 49ers kept trying to trade back into the first round to get Foster. They finally found a partner in the Seattle Seahawks at No. 31.

Foster was on the phone with the New Orleans Saints, learning they would take him at No. 32, the final selection of the first round, when the 49ers swung the deal and made the pick.

"The 30th and 31st picks were about to come up, so I get a call from the New Orleans Saints and they say, 'Are you in Louisiana, Baton Rouge?'" Foster said during his introductory press conference in San Francisco. "I said, 'No, sir. I'm in Miami, Florida.' 'Is your woman around?' I'm like, 'Hold up. Why do you want to speak to my woman?' They said, 'Give her the phone.' So I give her the phone and all I hear is, 'Yeah. No. Yes, sir. Yeah, we're in Miami. Yes, sir.' And I'm like: What are they talking about?

"That's when a click had come in, and she pulled the phone out like this, and I said, 'Oh, that's San Jose.' So I clicked over for the San Francisco 49ers, and I picked up and said, 'Hello,' while the New Orleans Saints are still on the line. But I wanted to be a 49er so bad. It was funny. It was crazy."

While off-the-field issues seem to have dissuaded some teams from selecting Foster as early as the 49ers had him projected to go, it didn't keep San Francisco from pursuing him.

The former Auburn High School standout was a unanimous All-American for Alabama in the 2016 season, when he won the Butkus Award as the nation's best linebacker. But Foster has had a bumpy offseason. He was sent home from the NFL Scouting Combine after getting into an argument with a hospital worker during medical testing, had a diluted urine sample there, which counts as a failed drug test in the NFL's eyes, and underwent shoulder surgery after the season.