I don't recommend taking immigration to court, they can be very 'mai po jai' or resentful, with serious consequences.
It's better to contact the Ombudsman.
https://www.ombudsman.go.th/
Alternatively, contact some police friend to have a word.
Once I went to Nong Kai immigration with some influential Khon Kaen people, including a University rector, who just happened to be travelling to NK for a funeral so took me along and came into the immigration wearing their white uniforms. This is when Khon Kaen didn't have an immigration. The immigration guy flexed his muscles and felt like his kingdom was being invaded and sent them on their way and the consequences were painful for me, I had to travel to Nong Kai every month for nearly a year.
Much different story when I had a problem and got a police friend, who was in charge of 7 Northern provinces to have a word!
Another suggesting I have is to contact some politicians to look into it.
Once upon a time, Khon kaen Imm had a tip box. I contacted former Minister of Finance, Korn Chatikavanich, who posted the phot of it on his Facebook page,