High Sierra doesn't boot after ubuntu partition deletion (which was dual booted)
I know it's while I opened this thread but I finally understand what is the problem and how to fix it.

The problem is that after merging the partitions the Disk Utility somehow destroyed the partition type (APFS partition), and changed it to 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFF'. There was similar questions related to my issue here and here.

I imaged the whole disk and installed the OS from scratch and with the instructions mentioned in the links I managed to mount the image and access my data. But it was possible to fix the problem without reinstalling and imaging.

Anyway here is the commands I used after installing new OS to solve the issue on the disk image.

First mount the raw image (I imaged the disk with dd).

sudo hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount hard.dmg


here is my output, as you can see the third partition type is invalid.

/dev/disk3              GUID_partition_scheme           
/dev/disk3s1            EFI                             
/dev/disk3s2            FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFF 


Get information about disk layout and start and size of each partitions.

sudo gpt -r show /dev/disk3


here is the output

      start       size  index  contents
          0          1         PMBR
          1          1         Pri GPT header
          2         32         Pri GPT table
         34          6         
         40     409600      1  GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
     409640  927867256      2  GPT part - FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
  928276896   48828131         
  977105027         32         Sec GPT table
  977105059          1         Sec GPT header


So I just need to remove the third partition and add it again with the right GUID, I also used the start and size from previous command. the GUID for APFS partition is 7C3457EF-0000-11AA-AA11-00306543ECAC.

gpt  remove  -i  2  /dev/disk3
gpt  add -i 2 -b 409640 -s 927867256 -t 7C3457EF-0000-11AA-AA11-00306543ECAC disk3