It's difficult to tell from the screenshot.
I suggest changing layer interactivity instead. When layer interactive=No, it doesn't receive mouse and touch events. So you will not need to check for layer/sprite visibility.
Also, I suggest always using layer names in events rather than layer numbers. If you decide to add/remove any layers in the future, you will have to update layer numbers in all events. With names you won't have this problem.