This phase II trial studies how well giving a JAK inhibitor before a donor stem cell transplant works in treating patients with myelofibrosis that developed without another condition (primary) or evolved from other bone marrow disorders (secondary). JAK inhibitors are a class of drugs that may stop the growth of abnormal cells by blocking an enzyme needed for cell growth. Giving a JAK inhibitor before a donor stem cell transplant may help reduce symptoms of myelofibrosis such as inflammation and enlargement of the spleen, improve the patient's general physical condition, and prevent complications from occurring after the transplant. Infusing healthy stem cells from a donor into the patient may help the patient's bone marrow work normally and make stem cells, red blood cells, white blood cells, and platelets. Giving a JAK inhibitor before a donor stem cell transplant may help improve transplant outcomes in patients with myelofibrosis.