An algorithm for grouping items according to “constrains” and “preferences”

Before i explain exactly what i mean, let me just say that i never studied CS or low level programming, so i don’t know much about the subject(I’m a self-taught JS programmer). To the point:

Imagine you have a group of workers, you need to construct a work-schedule for. Each worker has “constrains”, meaning days/shifts(each day has three shifts, let’s say) they can’t work on, and “preferences”, meaning their more desired shifts.

For example, John declares: “Can’t work on Thursday at all; Can’t work on Tuesday morning; Would like to have at least 4 shifts this week”.

So imagine, that you have many shifts and many workers, and you need to construct a schedule that takes into consideration their requests as much as possible.

I’m sure this problem was already addressed. Can you maybe point me to the right direction, and direct me to some algorithm/methodology, from where i can start?