Unfortunately, it's impossible to say why this is happening. as to the flap, you may remove the flap for now and let the cats come and go. As they become more comfortable, put the flap back in and entice them through the flap with treats or food. They may be afraid of it.
Sleeping in the litter box could indicate stress or illness. Make sure the cat is healthy and try to eliminate stress. Here is a great article about cat's instinctual needs:
https://www.petcoach.co/article/why-every-cat-needs-a-place-to-climb/Use a Feliway diffuser, set aside 30 minutes a day for vigorous play and/or switch the food to Royal Canin Calm. Most cats response best to combination therapy. The veterinarian can also prescribe medications which can help with house soiling. I hope this helps and please feel free to post any additional questions.