According to NASA, astronauts do not use compasses in space, but near-earth orbit would not change the behavior of the magnetic needle significantly.
If the compass were in the cockpit of an orbiter, it would probably behave much as it does on earth.
The needle would follow the lines of the planet’s doughnut-shaped magnetic field and pointing toward the north.
There might be some areas of magnetic flux in which the lines might not be exactly aligned, but that would be an occasional exception.
In outer space, the situation is not so clear.
Theoretically, a compass is affected by the most prevalent and biggest magnetic source available, and would follow whatever lines of force there were.
Depending on how far out the vessel carrying the compass is, that source might be the earth or even something in the vessel.
NASA scientists said that it was impossible to predict such behavior exactly from what is now known.