Trying to use a bed with a monster nearby that is within 8 blocks of the bed head horizontally in the X- and Z-axis and 5 blocks vertically in the Y-axis will allow players to fall asleep. In other words, trying to use a bed within close proximity of a monster will allow players to sleep regardless.
Steps to reproduce
Place a bed near a monster that is within 8 blocks of the bed head horizontally and 5 blocks vertically.
Use the bed. Instead of it displaying the "You may not rest now; there are monsters nearby" message, it will let players use the bed normally.
Would MC-92719 describe you're issue?