Depending on if a screen exists in a certain stack I need to be able to do different things in my code. I have tried my best but I haven't found anything on the matter. Is there an easy way to achieve this?
If you mean, you want to get all the routes inside the current navigator, then I think this will fix your problem.
const navigation = useNavigation();
const routes = navigation.dangerouslyGetState().routeNames;