Joining all meshes in any context gets error
Make sure one of your mesh objects is active. You will get that error if you try to join without one being active.

This works with 2.80

import bpy

#Deselect all
bpy.ops.object.select_all(action='DESELECT')

#Mesh objects
MSH_OBJS = [m for m in bpy.context.scene.objects if m.type == 'MESH']

for OBJS in MSH_OBJS:
    #Select all mesh objects
    OBJS.select_set(state=True)

    #Makes one active
    bpy.context.view_layer.objects.active = OBJS

#Joins objects
bpy.ops.object.join()