Prior to the USS Enterprise-D's first encounter with the Borg, the Federation had knowledge of their existence, based on encounters with surviving members of species that had been destroyed by them (such as the El-Aurians). However, empirical data on the Borg was very scarce: for example, there were descriptions of cube-shaped vessels, but no information on what Borg individuals looked like, other than rumors that they were cybernetically enhanced.
The Hansens' mission
In 2353, Magnus and Erin Hansen petitioned the Federation Council on Exobiology to support them on an independent research mission to study the Borg. The Council agreed, providing them with a vessel, the USS Raven, despite security concerns expressed by Starfleet.
They made their preparations and, on stardate 32611, with Annika in tow, they set off. They made a stop at the Drexler outpost in the Omega sector, as recorded in the logs of the space station Deep Space 4. After leaving the station, however, they deviated from their flight plan, disobeyed direct orders to return and crossed into the Romulan Neutral Zone, effectively leaving the protection of Federation space. After tracking stray readings and sensor echoes for eight months, the Hansens were able to locate a Borg cube. The Raven trailed the cube, following it into a transwarp conduit all the way to the region of the Borg's origin, the Delta Quadrant.
The Hansens designed new technologies to allow themselves to study the Borg more closely and prevent the Borg from detecting them. They developed multi-adaptive shielding that make the Raven virtually invisible to Borg sensors, and bio-dampeners to mask their biosigns while on Borg vessels. Magnus visited Borg cubes in person to observe first-hand the behavior and interactions of drones. He and Erin also transported regenerating drones onto the Raven for study. The Hansens became very well-versed and comfortable in their endeavor, even giving them nicknames such as "Junior" and "Needle Fingers." They continued exploration of the Borg for over three years, collecting ten million teraquads of data.
Then in 2356 on Stardate 32634.9, the mission came to a disastrous end. A subspace particle storm damaged the Raven's multi-adaptive shielding, putting it off-line for 13.2 seconds. The Borg detected the Raven and deemed it a threat. Pursuit of the Raven began and attempts to escape them by masking the ship's warp trail failed. The Borg caught the ship and assimilated the Hansens and their daughter who later became known as Seven of Nine. The Raven itself was partially assimilated, but the Borg chose not to keep it, and it eventually crash-landed on a M-class moon orbiting the fifth planet of a yellow dwarf star in the region controlled by the species known as the B'omar. The Hansens' field notes, contained in 9,000-plus log entries, were retrieved in 2374 by the Federation starship USS Voyager from the wreckage of the Raven. (VOY: "The Raven")
The Voyager crew used the Hansens' data in 2375 in their successful theft of a transwarp coil from a Borg sphere. In the course of this caper, Seven of Nine, who had been freed from the Borg, de-assimilated and become a member of the Voyager crew, was forced to surrender herself to the Borg under threat by the Borg Queen to assimilate Voyager. While with the Borg, she encountered her assimilated father in the Queen's chamber. When the Voyager crew later rescued Seven of Nine, the Borg Queen's vessel was destroyed but it is uncertain if the drone that used to be Magnus Hansen was aboard at the time. (VOY: "Dark Frontier")
Magnus Hansen's appearance in "Scorpion, Part II" was not scripted, with the shooting script of "The Raven" being the first teleplay to feature the character. In the script for the latter episode, however, he is merely described as "a rugged man." The script of "Dark Frontier" describes him in significantly more detail, introducing him by stating, "He looks to be in his late 30s to early 40s, wears casual, non-Starfleet clothing, and his hair is always a bit mussed. He has an unconventional air about him, and his eyes are filled with intelligence and humor."