I wonder why there are some subhalos(with SubhaloFlag==1) not in the tree (e.g. subhaloID==507395 in TNG50-1 at snapNum==99 )?
This subhalo is very low-mass, and contains only stars (no gas, no DM). There are really two possibilities: (i) this is a real satellite galaxy which has been substantially stripped, and probably been so close to the central in its orbit for enough snapshots that Subfind (or the merger tree algorithm) wasn't able to identify it in the past, or (ii) this is a fragment or piece, either a stellar clump which has broken off from another galaxy, or (if the stars are young), it could have formed from a gas clump with a similar origin.
If you really want to dig into why, you could either (i) get the IDs of the 187 star particles in the subhalo, and find them again at snapshots 98, 97, ..., and see where they are, or (ii) look at images of (stellar density in) the host halo (ID 156) at snapshots 99, 98, 97... to see if you can visually identify this subhalo and where it came from.
I got it, thank you Dylan