We don't have a canonical answer to this question. It is possible, as Ian Newson speculates in the comments, that Harry and his ship were similar enough to the gormagander's normal stomach contents as not to appear anomalous on initial sensor scans. It is also possible that the gormagander's natural composition is sufficiently sensor-obscuring as to require greater proximity to detect abnormalities.
Whether any of the above scenarios, or something with a similar effect, is ever introduced into canon is immaterial. We don't know for certain that the first iteration of the time loop we see on screen is the first iteration that Harry and Discovery have experienced. While Stamets doesn't show clear awareness of the time loop at first, it is possible that it took a few loops before he started manifesting conscious knowledge of the loop.
It is therefore possible that in the initial loops, Harry was discovered in the gormaganger, or in whatever ruse he initially attempted. He may have then refined his technique until he found countermeasures which succeeded in getting him on board. In these instances, it is likely that Harry triggered a new iteration of the loop before Stamets's routine was disturbed, possibly contributing to his lack of awareness prior to Harry successful infiltration.