I am in my last semester of undergrad (majoring in mathematics) and am currently working on applying to PhD programs (in mathematics). During the fall of 2016 due to a health issue that lasted for the majority of the semester and the general difficulty of the course I received a D in Topology. Topology is not a required course at my university, but is an elective in my major. I was going to immediately retake the course, but my school has not offered the course since I last took it until this semester (fall of 2018). So, I could retake it this semester (and am currently planning on it), but my applications will need to be submitted before the new grade can be recorded, so I will have to submit my application with the D on my transcript.
I have done everything in my power to try to remedy this flaw on my transcript. I have a ~3.7 (3.68 exact) overall GPA and subject GPA (although if I had the chance to retake the course my mathematics GPA would be a ~3.8), as well as having received permissions from the department to take several graduate courses as an undergraduate in which my GPA is a 4.0 and taken several courses that cover and use topological concepts and received A's in them. I strongly believe that given the chance to retake the course I would have no problems receiving an A (or using topological concepts in research/other classes) since I have already mastered topological concepts in a variety of other courses as well as my prior knowledge from my first time taking the course.
I also have prior research experience from my freshman year (in a different engineering area since my freshman year I was a computer science major) and will also be starting mathematics research during this coming semester, so I will most likely not publish anything but will have research experience. My GRE scores are average to slightly above average according to GRE data that I have looked at and will be retaking the GRE to improve my scores even further next week and my letters of recommendation will be strong as I have worked closely for years with all of my recommenders.
Will this bad grade effect my chances of getting into a PhD program? Should I apply to a masters program first? Should I retake topology this semester even though admissions committees will not see the new grade until after I have received a decision? Any advice would be appreciated!
(Note: I have read a handful of other posts on here about one bad grade, but none seemed to quite match the dilemma of a bad grade in an upper level elective in one's field of study. Thanks!)